Opened 4 years ago

Closed 4 years ago

#1439 closed defect (fixed)

smartmontools compile fails with "undefined reference to `__stack_chk_guard'"

Reported by: edso Owned by: Christian Franke
Priority: minor Milestone: Release 7.3
Component: all Version: 7.2
Keywords: Cc:

Description

the configure stackprotection detection

https://github.com/Freetz-NG/freetz-ng/issues/186#issuecomment-775178338

might wrongly detect support where there is none.

looks like a change as described here

https://github.com/apple/cups/issues/3198

would prevent that.

thanks!.. ede

Change History (7)

comment:1 by Christian Franke, 4 years ago

Milestone: undecided
Version: 7.2

Smartmontools 7.2 already includes the proposed fix, see r5032.

If this is not effective in your environment this is possibly because the current check does not actually generate calls to __stack_chk_*() functions.

If possible, please test:

  • configure.ac

     
    772772    AC_MSG_CHECKING([whether $CXX supports $option])
    773773    save_CXXFLAGS=$CXXFLAGS
    774774    CXXFLAGS="$CXXFLAGS $option"
    775     AC_LINK_IFELSE([AC_LANG_PROGRAM()], [res=yes], [res=no; CXXFLAGS=$save_CXXFLAGS])
     775    AC_LINK_IFELSE([AC_LANG_PROGRAM([[int i;]],
     776      [[volatile char buf[10]; buf[i] = 0;]])],
     777      [res=yes], [res=no; CXXFLAGS=$save_CXXFLAGS])
    776778    AC_MSG_RESULT([$res])
    777779  done
    778780else

comment:2 by edso, 4 years ago

sorry Christian,

still detects it as working s.b.

user@ubuntu:~/freetz-ng-7360v2$ make smartmontools-precompiled
mkdir -p packages/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2/root
if test -d make/smartmontools/files; then 	tools/tar-gnu -cf - -C make/smartmontools/files --exclude=.svn --exclude=.git --exclude=.gitignore --exclude=.build-prereq-checked --exclude=.unpacked --exclude=.configured --exclude=.compiled --exclude=.installed . | tools/tar-gnu -xf - -C packages/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2; fi
---> package/smartmontools ... preparing ... mkdir -p source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2; tools/gunzip -c dl/smartmontools-7.2.tar.gz | tools/tar-gnu -x -C source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2 --transform='s|^./\+||' --strip-components=1 
set -e; shopt -s nullglob; for i in make/smartmontools/patches/*.patch*; do case $i in *.patch|*.patch.gz|*.patch.bzip2|*.patch.bz2|*.patch.bz|*.patch.xz|*.patch.lz|*.patch.lzma|*.patch.Z) ;; *) continue ;; esac; tools/freetz_patch source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2 $i; done; 
    applying patch file make/smartmontools/patches/test.patch
    patching file configure.ac
    Hunk #1 succeeded at 766 (offset -6 lines).
    ----------------------------------------------------------------------
configuring ... (conf_cmd() { ./configure  "$@"  || { printf "\n\\033[33m%s\\033[m\n" "ERROR: Build failed.";  exit 1; } }; cd source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2;  rm -f config.{cache,status};    PATH="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin:/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5/mips-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" FREETZ_LIBRARY_DIR="/usr/lib/freetz" FREETZ_KERNEL_VERSION_MAJOR="3.10" FREETZ_TARGET_ARCH="mips" FREETZ_TARGET_ARCH_ENDIANNESS_DEPENDENT="mips" CC="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-gcc" CXX="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-g++-wrapper" CFLAGS="-march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" CXXFLAGS="-march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" LDFLAGS="" PKG_CONFIG_PATH="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/../lib/pkgconfig" PKG_CONFIG_LIBDIR="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/../lib/pkgconfig" GLOBAL_LIBDIR=/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/usr/lib  CONFIG_SITE=/home/user/freetz-ng-7360v2/include/config.site/mips-linux-uclibc conf_cmd   --cache-file=/dev/null --target=mips-linux --host=mips-linux --build=x86_64-pc-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --datadir=/usr/share --includedir=/usr/include --infodir=/usr/share/info --libdir=/usr/lib --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --sbindir=/usr/sbin --sysconfdir=/etc --with-gnu-ld --disable-nls --without-nvme-devicescan   )
configure: WARNING: unrecognized options: --with-gnu-ld, --disable-nls
configure: loading site script /home/user/freetz-ng-7360v2/include/config.site/mips-linux-uclibc
checking for a BSD-compatible install... /usr/bin/install -c
SNIP
checking whether os_linux.cpp uses new interface... yes
checking whether /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-g++-wrapper supports -fstack-protector-strong... no
checking whether /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-g++-wrapper supports -fstack-protector... yes
checking whether _FORTIFY_SOURCE is predefined... no
checking whether /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-g++-wrapper supports _FORTIFY_SOURCE=2... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
configure: WARNING: unrecognized options: --with-gnu-ld, --disable-nls
checking whether make sets $(MAKE)... (cached) yes
configure:
-----------------------------------------------------------------------------
smartmontools-7.2 configuration:
host operating system:  mips-unknown-linux-gnu
C++ compiler:           /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-g++-wrapper
C compiler:             /home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-gcc
preprocessor flags:     
C++ compiler flags:     -march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -fstack-protector
C compiler flags:       -march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
linker flags:           
OS specific modules:    os_linux.o cciss.o dev_areca.o  
binary install path:    /usr/sbin
man page install path:  /usr/share/man
doc file install path:  /usr/share/doc/smartmontools
examples install path:  /usr/share/doc/smartmontools/examplescripts
drive database file:    /usr/share/smartmontools/drivedb.h
database update script: /usr/sbin/update-smart-drivedb
database update branch: branches/RELEASE_7_2_DRIVEDB
download tools:         curl wget lynx svn
GnuPG for verification: gpg
local drive database:   /etc/smart_drivedb.h
smartd config file:     /etc/smartd.conf
smartd warning script:  /etc/smartd_warning.sh
smartd plugin path:     /etc/smartd_warning.d
PATH within scripts:    /usr/local/bin:/usr/bin:/bin
smartd initd script:    [disabled]
smartd save files:      [disabled]
smartd attribute logs:  [disabled]
SELinux support:        no
libcap-ng support:      no
systemd notify support: no
NVMe DEVICESCAN:        no
-----------------------------------------------------------------------------

cmd() { PATH="/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin:/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5/mips-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" LD_RUN_PATH="/usr/lib/freetz" FREETZ_LIBRARY_DIR="/usr/lib/freetz" make -j16  "$@"  || { printf "\n\\033[33m%s\\033[m\n" "ERROR: Build failed.";  exit 1; } }; 	if [ -e source/.echo_item_start -a ! -e source/.echo_item_build ]; then echo -ne "\e[48;5;56mbuilding\e[49m ... "; touch source/.echo_item_build; fi; cmd -C source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2
building ... make[1]: Entering directory '/home/user/freetz-ng-7360v2/source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2'
make  all-am
SNIP
/home/user/freetz-ng-7360v2/toolchain/build/mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/mips-linux-uclibc/bin/mips-linux-uclibc-g++-wrapper  -march=34kc -mtune=34kc -msoft-float -Os -pipe -Wa,--trap -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -W -fstack-protector   -o smartd smartd.o atacmdnames.o atacmds.o dev_ata_cmd_set.o dev_intelliprop.o dev_interface.o dev_jmb39x_raid.o knowndrives.o nvmecmds.o scsicmds.o scsiata.o scsinvme.o utility.o     os_linux.o cciss.o dev_areca.o      
smartd.o: In function `vsyslog_lines(int, char const*, void*)':
smartd.cpp:(.text+0x110): undefined reference to `__stack_chk_guard'
smartd.cpp:(.text+0x118): undefined reference to `__stack_chk_guard'
smartd.cpp:(.text+0x1a8): undefined reference to `__stack_chk_guard'
smartd.cpp:(.text+0x1b4): undefined reference to `__stack_chk_fail'
smartd.o: In function `read_ata_error_count(ata_device*, char const*, firmwarebug_defs, bool)':
SNIP
dev_areca.o: In function `generic_areca_device::arcmsr_scsi_pass_through(scsi_cmnd_io*) [clone .part.6]':
dev_areca.cpp:(.text+0xa68): undefined reference to `__stack_chk_guard'
dev_areca.cpp:(.text+0xa70): undefined reference to `__stack_chk_guard'
dev_areca.cpp:(.text+0xcdc): undefined reference to `__stack_chk_guard'
dev_areca.cpp:(.text+0xce8): undefined reference to `__stack_chk_fail'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1039: smartd] Error 1
make[2]: *** Waiting for unfinished jobs....
mv -f .deps/ataprint.Tpo .deps/ataprint.Po
make[2]: Leaving directory '/home/user/freetz-ng-7360v2/source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2'
make[1]: *** [Makefile:938: all] Error 2
make[1]: Leaving directory '/home/user/freetz-ng-7360v2/source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2'

ERROR: Build failed.
make: *** [make/smartmontools/smartmontools.mk:24: source/target-mips_gcc-4.8.5_uClibc-0.9.33.2-nptl_kernel-3.10/smartmontools-7.2/smartctl] Error 1

comment:3 by Christian Franke, 4 years ago

I don't see any autoconf, autoreconf or ./autogen.sh in the above protocol. Did you actually rebuild the configure script?

If GNU autotools are not available, please test whether this program could be build manually using the same compiler:

int i;

int main()
{
  volatile char buf[10];
  buf[i] = 0;
  return 0;
}

Try with and without -fstack-protector option.

comment:4 by edso, 4 years ago

sorry. not a Make/Autoconf guru myself.

you are right. manually running 'autoreconf' in a patched source dir solves this.

as long as it's unreleased how would you suggest to apply the fix to a buildroot package like the one in Freetz-NG?
https://github.com/Freetz-NG/freetz-ng/tree/master/make/smartmontools
i'd assume patching the configure script or?

thx!.. ede

comment:5 by Christian Franke, 4 years ago

Sorry, I'm not familiar with this build system. Various .../make/*/*.mk files there use this:

$(PKG)_CONFIGURE_PRE_CMDS += $(AUTORECONF)

This possibly runs autoreconf after the patch is applied.

comment:6 by Christian Franke, 4 years ago

Milestone: undecidedRelease 7.3
Owner: set to Christian Franke
Status: newaccepted

comment:7 by Christian Franke, 4 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.