1. gcc --version gcc (GCC) 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r2, propolice) -or- (whatever the gcc-3.3-r1.ebuild produces) 2. USE="ntpl" emerge =sys-libs/glibc-2.3.2-r3 3. echo "int main(void){return 42;}" > tiny.c 4. gcc -static tiny.c -o tiny 5. ls -sh tiny 480K tiny 6. ./tiny; echo $? 42 7. gcc -static -nostartfiles helloworld.c -o helloworld (helloworld.c is attachment 1 [details]) 8. ls -sh helloworld 476K helloworld 9. ./helloworld Segmentation fault With glibc-2.3.2-r1 (older NPTL), the test cases are each about 4K, and work fine. I have a Pentium III (mobile Coppermine). Floam verified this bug with an Athlon 2600XP. I will test a glibc-2.3.2-r3 with NPTL 0.56, building it with gcc-3.3.1 to see if anything improves. If not, then with gcc-3.4 (gcc-cvs). This is one half of bug 25299 -- the original bug reported two different problems.
Created attachment 16194 [details] Test C program, with custom entrypoint, that prints a classic message
> I will test a glibc-2.3.2-r3 with NPTL 0.56, building it with > gcc-3.3.1 to see if anything improves. If not, then with > gcc-3.4 (gcc-cvs). Well. Nothing improved. Bug still there. Interesting, though... gcc-3.4 (cvs 13-aug-2003) will compile and build glibc 2.3.2 with NPTL 0.56; my gcc-3.3.1 and 3.3 and 3.2.3 did not. But even though it builds, it is still broken. Drat. Now building Rhino's glibc-2.3.2_p2 from http://www.breakmygentoo.net (using gcc-3.4)... stay tuned...
> Now building Rhino's glibc-2.3.2_p2 with gcc-3.4 Nope. Compiles fine, but bug still there... Bottom line: stick with glibc-2.3.2-r1 (NPTL 0.28)
Yes, still broken with latest gcc/glibc/binutils. I have mailed to the lists some time back, but no response .....
Disable propolice from building (comment the PP... env variables in the build), and try again ?
You mean the PP variables in the GCC ebuild, right? I build GCC without -fstack-protector in CFLAGS, but not without the patch altogether... no wait, is that true? Hmm... GCC 3.4(cvs) has no such ProPolice patch available... and yup I've already tested it with GCC 3.4 --- so I don't think that avoiding the patch altogether in GCC is going to fix the problem with glibc.
Check my last comments in the prev bug - static bins do not segfault here although big (with/without propolice ..), and I do have nptl ....
I re-merged GCC, now 3.3.1-r1, and static bins no longer segfault. They are very large. This is with NPTL in glibc-2.3.2-r1, no stack protection.
Things NO LONGER SEGFAULT with a recent NPTL, with new GCC! This with gcc-3.3.1-r1 (This newer glibc/NPTL also plays well with new Java 1.4.2; Java now using native threads... that's another story... but it didn't work with 2.3.2-r1) I checked libc out from CVS, and made an ebuild with a recent NPTL; here are interesting settings from that ebuild: filter-flags "-fomit-frame-pointer -malign-double -fstack-protector" #strip-flags NPTL_VER="0.56" BRANCH_UPDATE="20030814" Here are my CFLAGS: CFLAGS="-fstack-protector -ftracer -pipe -march=pentium3 -O1 -fstrength-reduce -fprefetch-loop-arrays -finline-functions -fgcse -freduce-all-givs" Maybe the new GCC-3.3.1-r1 has fixed the problem?
bug is back. bottom line seems to be: glibc-2.3.2-r1 is latest stable version, no matter the gcc version. so far. but I notice that Sun JDK 1.4.2 does not utilize NPTL on glibc-2.3.2-r1; it does so with later versions.
Clarification: the bug that I get now is the same as azarah: In function `extract_cie_info': /space/var/tmp/portage/gcc-3.3.1/work/gcc-3.3.1/gcc/unwind-dw2.c:247: undefined reference to `strlen' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/libgcc_eh.a(unwind-dw2-fde-glibc.o)(.text+0x659): In function `get_cie_encoding': /space/var/tmp/portage/gcc-3.3.1/work/gcc-3.3.1/gcc/unwind-dw2-fde.c:274: undefined reference to `strlen' /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/libgcc_eh.a(unwind-dw2-fde-glibc.o)(.text+0x1651): In function `_Unwind_Find_FDE': /space/var/tmp/portage/gcc-3.3.1/work/gcc-3.3.1/gcc/unwind-dw2-fde-glibc.c:283: undefined reference to `dl_iterate_phdr' collect2: ld returned 1 exit status
I suspect this problem is related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7516 Try compiling test case with gcc --verbose... I replaced /usr/lib/libc.a (from glibc-2.3.2-r6) with the one from -2.3.2-r1 and the problem simply goes away... the helloworld.c test case is tiny (2kb) and works just fine!
Last time I checked, I only commited glibc-2.3.2-r5 this weekend, not -r6. Anyhow, its fixed with glibc-2.3.2-r5, gcc-3.3.1-r3 and binutils-2.14.90.0.6-r3 this side at least (gcc -r3 fixed it actually). It was an gcc issue that I tried to fix with -r2 which borked for some reason, but got fixed with -r3 (cvs update). PLease update and see if same for you.
I am using 3.3.1-r5, 2.3.2-r6, binutils 2.14.90.0.6-r6 and I get the crash with the attached test program. I also get mysqld crashing when i compile it statically (USE="static"), it crashes when I exit a mysql CLI session... are this somehow related ? If yes, whats the solution ? Thanks! PS: my objective is getting a stable NPTL statically linked mysqld binary so I can run it on another machine which doesnt run gentoo or NPTL enabled glibc but, of course, runs a NPTL capable kernel
>> I replaced /usr/lib/libc.a (from glibc-2.3.2-r6) with the one from -2.3.2-r1 >> and the problem simply goes away > > Last time I checked, I only commited glibc-2.3.2-r5 this weekend, not -r6. Whups, sorry... -r6 was an -r5 that I modified with NPTL_VER="0.59" and BRANCH_UPDATE="20030922"... > Anyhow, its fixed with glibc-2.3.2-r5, gcc-3.3.1-r3 and > binutils-2.14.90.0.6-r3 I will try this and report back.
drat, I meant a modified -r3, NOT -r5. I will test 2.3.2-r7 (the most recent one in portage) and report back.
Seems to be fixed in latest versions of gcc/glibc.
> Seems to be fixed in latest versions of gcc/glibc. building now, fingers crossed...
nope. dies horribly, same as usual.. glibc-2.3.2-r8 Martin, what exactly are you using for settings? I used -fstack-protector -pipe -mcpu=pentium3 -O2 -freorder-blocks with gcc (GCC) 3.3.2 20031022 (Gentoo Linux 3.3.2-r1, propolice) # gcc -static -nostartfiles helloworld.c -o helloworld # ls -sh helloworld 660K helloworld # ./helloworld Segmentation fault # ls -lh /usr/lib/libc.a -rw-r--r-- 1 root root 2.8M Oct 27 16:58 /usr/lib/libc.a # ls -lh working-r1/libc.a -rw-r--r-- 1 root root 2.7M Aug 28 16:09 working-r1/libc.a # cp /usr/lib/libc.a b0rked-libc-r8-libc.a # cp working-r1/libc.a /usr/lib # ls -lh /usr/lib/libc.a -rw-r--r-- 1 root root 2.7M Oct 27 17:07 /usr/lib/libc.a # cksum !$ cksum /usr/lib/libc.a 4217695161 2758238 /usr/lib/libc.a # cksum b0rked-libc-r8-libc.a 3944828163 2834272 b0rked-libc-r8-libc.a # gcc -static -nostartfiles helloworld.c -o helloworld # ls -sh helloworld 4.0K helloworld* # ./helloworld hello world!
re-building glibc without -fstack-protector did not work... by "latest gcc", do you mean gcc-cvs (3.4)?
Nope, latest unstable in tree (did a while back). I do not however use propolice ... ---------------------------- azarah@nosferatu tmp $ gcc -o foo foo.c -static azarah@nosferatu tmp $ ls -l foo -rwxr-xr-x 1 azarah azarah 710988 Oct 29 20:25 foo azarah@nosferatu tmp $ ./foo modf(17.123850): ix=17.000000, rx=0.123850 azarah@nosferatu tmp $ file foo foo: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.0, statically linked, not stripped azarah@nosferatu tmp $
I have: gcc 3.3.2-r2 glibc 2.3.2-r8 binutils 2.14.90.0.7 and I still see the crash , more info: # emerge info Portage 2.0.49-r15 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r8, 2.6.0-test9) ================================================================= System uname: 2.6.0-test9 i686 Gentoo Base System version 1.4.3.11 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-O3 -march=pentium4 -funroll-loops -fprefetch-loop-arrays -pipe" CHOST="i686-pc-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/" CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" CXXFLAGS="-O3 -march=pentium4 -funroll-loops -fprefetch-loop-arrays -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="sandbox ccache autoaddcvs" GENTOO_MIRRORS="http://www.fhh.opensource-mirror.de/gentoo.org/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://mirrors.sec.informatik.tu-darmstadt.de/gentoo" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.de.gentoo.org/gentoo-portage" USE="x86 apm arts avi crypt cups encode foomaticdb gif imlib jpeg libg++ libwww mad mikmod motif mpeg ncurses nls oggvorbis opengl pdflib png qt quicktime spell truetype xml2 xmms xv zlib gdbm berkdb slang readline mysql tcpd pam ssl perl python -X -gtk -gnome -alsa -oss sse mmx -kde -gtk2 -svga -java -sdl nptl -gpm"
*bump* Can we close this bug? With recent gcc-3.4-r6 on a hardened gentoo profile (PIE and SSP), I get these results: lurch root # gcc -static -nostartfiles hello.c -o hello lurch root # ls -sh hello 520K hello* lurch root # ./hello hello world! That is, it is large, but it seems to work!
Never mind about closing this.. it is STILL a problem. No doubt you understand better why this would be... something related to duplicate SSP in GCC and GLIBC, I recall... After boostrap-build of gcc, then glibc, the executable is large but works, as in my post earlier today. Now that I have completed an "emerge -ue world" with the new compiler/glibc, I get the "Segmentation Fault" behavior.
hey, i could not recompute that: but maybe i am just too foolish... 15:14:54 [/space/pappy/chroots/chroot001:10702.pts-78.evildrop]evildrop /tmp # cat testcrash.sh #!/bin/bash gcc -static -nostdlib -nostartfiles \ -o ./testcrash \ -Wl,-dynamic-linker=/lib/ld-linux.so.2 \ /usr/lib/crti.o \ `gcc --print-file-name=crtbegin.o` \ ./testcrash.c \ /lib/libc.so.6 \ /usr/lib/libc_nonshared.a \ -lgcc -lgcc_eh \ `gcc --print-file-name=crtend.o` \ /usr/lib/crtn.o ./testcrash ; echo $? # ./testcrash.sh hello world! 0 compiled and works... here is the full gcc -v compiler output # ./testcrash.sh Reading specs from /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/specs Configured with: /var/tmp/portage/gcc-3.3.3-r6/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/sparc-unknown-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/sparc-unknown-linux-gnu/3.3 --mandir=/usr/share/gcc-data/sparc-unknown-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/sparc-unknown-linux-gnu/3.3/info --enable-shared --host=sparc-unknown-linux-gnu --target=sparc-unknown-linux-gnu --with-system-zlib --enable-languages=c,c++ --enable-threads=posix --enable-long-long --disable-checking --disable-libunwind-exceptions --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --disable-multilib --enable-__cxa_atexit --enable-clocale=generic Thread model: posix gcc version 3.3.3 20040412 (Gentoo Hardened Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6) /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/cc1 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -D__ELF__ -Dunix -D__sparc__ -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__sparc__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=unix -Asystem=posix -D__GCC_NEW_VARARGS__ -Acpu=sparc -Amachine=sparc ./testcrash.c -quiet -dumpbase testcrash.c -auxbase testcrash -version -o /tmp/ccTINaSO.s GNU C version 3.3.3 20040412 (Gentoo Hardened Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6) (sparc-unknown-linux-gnu) compiled by GNU C version 3.3.3 20040412 (Gentoo Hardened Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include" ignoring nonexistent directory "/usr/sparc-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/include /usr/include End of search list. /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/../../../../sparc-unknown-linux-gnu/bin/as -V -Qy -s -relax -o /tmp/cccUTynD.o /tmp/ccTINaSO.s GNU assembler version 2.14.90.0.8 (sparc-unknown-linux-gnu) using BFD version 2.14.90.0.8 20040114 /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/collect2 -m elf32_sparc -Y P,/usr/lib -relax -static -z relro -z now -o ./testcrash -L/usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3 -L/usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/../../../../sparc-unknown-linux-gnu/lib -L/usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/../../.. -dynamic-linker=/lib/ld-linux.so.2 /usr/lib/crti.o /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/crtbegin.o /tmp/cccUTynD.o /lib/libc.so.6 /usr/lib/libc_nonshared.a -lgcc -lgcc_eh /usr/lib/gcc-lib/sparc-unknown-linux-gnu/3.3.3/crtend.o /usr/lib/crtn.o hello world! 0 15:15:39 [/space/pappy/chroots/chroot001:10702.pts-78.evildrop]evildrop /tmp # emerge info Portage 2.0.50-r8 (default-sparc64-2004.0, gcc-3.3.3, glibc-2.3.3_pre20040420-r0, 2.6.6) ================================================================= System uname: 2.6.6 sparc64 sun4u Gentoo Base System version 1.4.16 Autoconf: sys-devel/autoconf-2.59-r4 Automake: sys-devel/automake-1.8.5 ACCEPT_KEYWORDS="sparc ~sparc" AUTOCLEAN="yes" CFLAGS="-O2 -mcpu=ultrasparc" CHOST="sparc-unknown-linux-gnu" COMPILER="gcc3" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O2 -mcpu=ultrasparc" DISTDIR="/usr/portage/distfiles" FEATURES="ccache sandbox" GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://www.ibiblio.org/pub/Linux/distributions/gentoo" MAKEOPTS="-j16" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="X arts avi berkdb crypt cups encode esd fbcon foomaticdb gdbm gif gnome gtk hardened imlib jpeg kde libwww mad mikmod motif mpeg ncurses nls oggvorbis opengl oss pam pdflib perl png python qt readline sdl slang sparc spell ssl tcpd truetype xml2 xmms xv zlib"
notice the missing /usr/lib/crt1.o from the -nostdlib -nostartfiles section of the manual gcc compiler activation. "only" loading an executable with -nostartfiles and not giving the necessary objects for loading MAY work (and in fact it did in your case) but should NOT work normally... is there something wrong with my thinking here? -Alex
fix and close or test and reopen cheers, alex (no reply is also an reply for me: it works, no need to argue any more)