# smartmontools crashes under FreeBSD / ppc. Is this a known issue?



## tingo (Jan 25, 2011)

Hello,
I'm running FreeBSD 9.0-current on a PowerMac G5:

```
root@kg-g5# uname -a
FreeBSD kg-g5.kg4.no 9.0-CURRENT FreeBSD 9.0-CURRENT #119 r217462M: Sat Jan 15 16:05:38 CST 2011
     root@comporellon.tachypleus.net:/usr/obj/powerpc.powerpc/usr/src/sys/GENERIC  powerpc
```
I have installed smartmontools from ports:

```
root@kg-g5# pkg_info | grep smartmontools
smartmontools-5.40  S.M.A.R.T. disk monitoring tools
```
Which looks ok, but doesn't really work:

```
root@kg-g5# smartctl
smartctl 5.40 2010-10-16 r3189 [FreeBSD 9.0-CURRENT powerpc] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

ERROR: smartctl requires a device name as the final command-line argument.


Use smartctl -h to get a usage summary

root@kg-g5# smartctl -H /dev/ad0
smartctl 5.40 2010-10-16 r3189 [FreeBSD 9.0-CURRENT powerpc] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

Segmentation fault (core dumped)
root@kg-g5# smartctl -a /dev/ad0
smartctl 5.40 2010-10-16 r3189 [FreeBSD 9.0-CURRENT powerpc] (local build)
Copyright (C) 2002-10 by Bruce Allen, http://smartmontools.sourceforge.net

Segmentation fault (core dumped)
```
Is this a known issue? I googled it, but didn't find anything related.


----------



## tingo (Jul 20, 2012)

It also crashes on an iBook G4 running FreeBSD 9.1-prerelease:

```
root@kg-ibook# uname -a
FreeBSD kg-ibook.kg4.no 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0: Thu Jul 19 11:26:56 CEST 2012
     root@kg-ibook.kg4.no:/usr/obj/usr/src/sys/GENERIC  powerpc
```
Details:

```
root@kg-ibook# pv | grep smart
smartmontools-5.43          =  up-to-date with port 
root@kg-ibook# smartctl
smartctl 5.43 2012-06-30 r3573 [FreeBSD 9.1-PRERELEASE powerpc] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

ERROR: smartctl requires a device name as the final command-line argument.


Use smartctl -h to get a usage summary
root@kg-ibook# smartctl -a /dev/ada0
smartctl 5.43 2012-06-30 r3573 [FreeBSD 9.1-PRERELEASE powerpc] (local build)
Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

Segmentation fault (core dumped)
```
and gdb backtrace

```
root@kg-ibook# gdb smartctl smartctl.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-marcel-freebsd"...(no debugging symbols found)...
Core was generated by `smartctl'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcam.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libcam.so.6
Reading symbols from /usr/lib/libusb.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libusb.so.2
Reading symbols from /usr/lib/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libm.so.5
Reading symbols from /lib/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /lib/libsbuf.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/libsbuf.so.6
Reading symbols from /lib/libthr.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libthr.so.3
Reading symbols from /usr/lib/libsupc++.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libsupc++.so.1
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x41b4c2ac in strcmp () from /lib/libc.so.7
Cannot find new threads: generic error
(gdb) 
(gdb) bt
#0  0x41b4c2ac in strcmp () from /lib/libc.so.7
#1  0x0180d93c in std::operator+<char, std::char_traits<char>, std::allocator<char> > ()
#2  0x0181dd04 in std::operator+<char, std::char_traits<char>, std::allocator<char> > ()
#3  0x0181fa80 in std::operator+<char, std::char_traits<char>, std::allocator<char> > ()
#4  0x01820334 in std::operator+<char, std::char_traits<char>, std::allocator<char> > ()
#5  0x0180764c in ?? ()
```
Unfortunately, that's all I got.


----------



## kpa (Jul 20, 2012)

http://forums.freebsd.org/showthread.php?t=32747

It's probably a bug in the old gcc(1) 4.2.1 on ppc, I worked around it by turning off optimizations with custom CXXFLAGS for the port /etc/make.conf


```
.if ${.CURDIR:M*/sysutils/smartmontools}
CXXFLAGS=-O0 -pipe -Wno-write-strings -Wall -W
.endif
```

Compiling the port with lang/gcc46 as I noted in the other thread works fine without custom CXXFLAGS.


----------



## tingo (Jul 20, 2012)

Yes, using your /etc/make.conf settings got me a working smartmontools - thanks!
Now `# smartctl -a /dev/ada0` works without problems.
I see one small thing when starting smartd:

```
root@kg-ibook# service smartd status
smartd is not running.
root@kg-ibook# service smartd start
Starting smartd.
(pass0:ata0:0:0:0): ATA_IDENTIFY. ACB: ec 00 00 00 00 40 00 00 00 00 01 00
(pass0:ata0:0:0:0): CAM status: ATA Status Error
(pass0:ata0:0:0:0): ATA status: 51 (DRDY SERV ERR), error: 04 (ABRT )
(pass0:ata0:0:0:0): RES: 51 04 00 00 00 00 00 00 00 01 00
root@kg-ibook# service smartd status
smartd is running as pid 6612.
```
Not sure what that is about.


----------

