Bug 144112 - build failure : undefined reference to __stack_chk_fail
Summary: build failure : undefined reference to __stack_chk_fail
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: 3.2.3
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-12 02:18 UTC by Serhat Sevki Dincer
Modified: 2007-05-02 12:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serhat Sevki Dincer 2007-04-12 02:18:15 UTC
i downloaded valgrind 3.2.3 source code from valgrind.org and tried the usual
./configure --prefix=...
make
and the build stopped giving an error.

I have a pentium m laptop with xubuntu 6.10. gcc -v gives
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)

and uname -a gives
Linux Gauss 2.6.17-11-generic #2 SMP Tue Mar 13 23:32:38 UTC 2007 i686 GNU/Linux

output of ./configure --prefix=/media/Depo/Program/valgrind
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether ln -s works... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking for ranlib... ranlib
checking for perl... /usr/bin/perl
checking for gdb... /usr/bin/gdb
checking for a supported version of gcc... ok (gcc (GCC) 4.1.2 20060928
(prerelease) (Ubuntu 4.1.1-13ubuntu5))
checking build system type... i686-pc-linux
checking host system type... i686-pc-linux
checking for a supported CPU... ok (i686)
checking for use as an inner Valgrind... no
checking for a 64-bit only build... no
checking for a 32-bit only build... no
checking for a supported OS... ok (linux)
checking for the kernel version... 2.6 family (2.6.17-11-generic)
checking for a supported CPU/OS combination... ok (i686-linux)
checking for egrep... grep -E
checking the glibc version... 2.4 family
checking for X... libraries , headers 
checking if gcc accepts -m32... yes
checking if gcc accepts -m64... yes
checking if gcc accepts -mmmx... yes
checking if gcc accepts -msse... yes
checking if gcc accepts -mpreferred-stack-boundary... yes
checking if gcc accepts -Wno-pointer-sign ... yes
checking if gcc accepts -Wdeclaration-after-statement ... yes
checking if gcc supports __builtin_expect... yes
checking if ppc32/64 as supports mtocrf/mfocrf... no
checking for TLS support... yes
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sys/endian.h usability... no
checking sys/endian.h presence... no
checking for sys/endian.h... no
checking endian.h usability... yes
checking endian.h presence... yes
checking for endian.h... yes
checking mqueue.h usability... yes
checking mqueue.h presence... yes
checking for mqueue.h... yes
checking for uid_t in sys/types.h... yes
checking for off_t... yes
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking for working memcmp... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... yes
checking return type of signal handlers... void
checking for floor... no
checking for memchr... yes
checking for memset... yes
checking for mkdir... yes
checking for strchr... yes
checking for strdup... yes
checking for strpbrk... yes
checking for strrchr... yes
checking for strstr... yes
checking for semtimedop... yes
checking for usable MPI2-compliant mpicc and mpi.h... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating valgrind.spec
config.status: creating valgrind.pc
config.status: creating docs/Makefile
config.status: creating docs/lib/Makefile
config.status: creating docs/images/Makefile
config.status: creating docs/internals/Makefile
config.status: creating docs/xml/Makefile
config.status: creating tests/Makefile
config.status: creating tests/vg_regtest
config.status: creating perf/Makefile
config.status: creating perf/vg_perf
config.status: creating include/Makefile
config.status: creating auxprogs/Makefile
config.status: creating coregrind/Makefile
config.status: creating memcheck/Makefile
config.status: creating memcheck/tests/Makefile
config.status: creating memcheck/tests/amd64/Makefile
config.status: creating memcheck/tests/ppc32/Makefile
config.status: creating memcheck/tests/ppc64/Makefile
config.status: creating memcheck/tests/x86/Makefile
config.status: creating memcheck/docs/Makefile
config.status: creating cachegrind/Makefile
config.status: creating cachegrind/tests/Makefile
config.status: creating cachegrind/tests/amd64/Makefile
config.status: creating cachegrind/tests/ppc32/Makefile
config.status: creating cachegrind/tests/ppc64/Makefile
config.status: creating cachegrind/tests/x86/Makefile
config.status: creating cachegrind/docs/Makefile
config.status: creating cachegrind/cg_annotate
config.status: creating callgrind/Makefile
config.status: creating callgrind/callgrind_annotate
config.status: creating callgrind/callgrind_control
config.status: creating callgrind/tests/Makefile
config.status: creating callgrind/docs/Makefile
config.status: creating helgrind/Makefile
config.status: creating helgrind/tests/Makefile
config.status: creating helgrind/docs/Makefile
config.status: creating massif/Makefile
config.status: creating massif/hp2ps/Makefile
config.status: creating massif/tests/Makefile
config.status: creating massif/docs/Makefile
config.status: creating lackey/Makefile
config.status: creating lackey/tests/Makefile
config.status: creating lackey/docs/Makefile
config.status: creating none/Makefile
config.status: creating none/tests/Makefile
config.status: creating none/tests/amd64/Makefile
config.status: creating none/tests/ppc32/Makefile
config.status: creating none/tests/ppc64/Makefile
config.status: creating none/tests/x86/Makefile
config.status: creating none/docs/Makefile
config.status: creating config.h
config.status: executing depfiles commands

   Primary build target: X86_LINUX
 Secondary build target: 
     Default supp files: xfree-3.supp xfree-4.supp glibc-2.4.supp 

output of make (skipping everything except)
memcheck_x86_linux-mc_main.o: In function `mc_post_reg_write':
/home/jfcgauss/Desktop/valgrind-3.2.3/memcheck/mc_main.c:2200: undefined
reference to `__stack_chk_fail'
memcheck_x86_linux-mc_main.o: In function `mc_pre_reg_read':
/home/jfcgauss/Desktop/valgrind-3.2.3/memcheck/mc_main.c:2235: undefined
reference to `__stack_chk_fail'
../coregrind/libcoregrind_x86_linux.a(libcoregrind_x86_linux_a-m_errormgr.o): In
function `is_suppressible_error':
/home/jfcgauss/Desktop/valgrind-3.2.3/coregrind/m_errormgr.c:1153: undefined
reference to `__stack_chk_fail'
../coregrind/libcoregrind_x86_linux.a(libcoregrind_x86_linux_a-m_errormgr.o): In
function `vgPlain_load_suppressions':
/home/jfcgauss/Desktop/valgrind-3.2.3/coregrind/m_errormgr.c:1075: undefined
reference to `__stack_chk_fail'
../coregrind/libcoregrind_x86_linux.a(libcoregrind_x86_linux_a-m_libcbase.o): In
function `vgPlain_ssort':
/home/jfcgauss/Desktop/valgrind-3.2.3/coregrind/m_libcbase.c:510: undefined
reference to `__stack_chk_fail'
../coregrind/libcoregrind_x86_linux.a(libcoregrind_x86_linux_a-m_libcfile.o):/home/jfcgauss/Desktop/valgrind-3.2.3/coregrind/m_libcfile.c:440:
more undefined references to `__stack_chk_fail' follow
collect2: ld returned 1 exit status
make[3]: *** [memcheck-x86-linux] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Comment 1 Nicholas Nethercote 2007-04-12 08:38:00 UTC
We've never seen this one before.

I couldn't find any mention of __stack_chk_fail in the Valgrind sources.  It looks like something that might be used by the C compiler if you had some kind of bounds checking extension like mudflap turned on.  Valgrind doesn't link with any external libraries, including libc and libgcc, so any such extension is unlikely to work.  Do you know if your C compiler is trying to do something like that?
I wonder if the --enable-libstdcxx-debug configure flag to GCC has something to do with it.
Comment 2 Serhat Sevki Dincer 2007-04-12 08:50:22 UTC
i just do
./configure --prefix=/some/path
make
and the make step fails with the above error. i dont give any other option to gcc, and mine is a default install of xubuntu 6.10 (an official variant of ubuntu). i did some googling, and i think it has something to do with -f[no-]stack-protector option of gcc 4.X (it's under "Optimization Options" in the GCC 4.1.2 Manual). i added -fno-stack-protector to a lot of Makefiles, wherever i see "CFLAGS" and it compiled, and ran (dont know if i added to right/appropriate places in the Makefiles, and if the final valgrind works correctly).
Comment 3 Julian Seward 2007-05-01 15:44:29 UTC
Possibly fixed on the trunk by r6721.
Comment 4 Julian Seward 2007-05-02 12:28:58 UTC
Fixed (trunk r6721, 3_2_BRANCH r6724).