BusyBox Bug and Patch Tracking
BusyBox
  

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002834 [uClibc] Posix Threads major always 04-04-08 12:08 04-29-08 08:44
Reporter hank_le View Status public  
Assigned To uClibc
Priority normal Resolution open  
Status feedback   Product Version
Summary 0002834: libc_pthread_init() causes segfault
Description Initializing programs that link to libpthread segfault. Simple "Hello World" program segfaults when linked against libpthread, yet runs fine without. Attached pthread_test.c won't run.
Additional Information using buildroot snapshot from today, uClibc-0.9.29, NPTL, I get a segfault during initialization. I'm using gcc-4.2.1, binutils-2.18. Attached code compiled as:

 export PATH_TO_BUILDROOT=/home/henry/src/buildroot
 export CC=$PATH_TO_BUILDROOT/build_i586/staging_dir/usr/bin/i586-linux-gcc
 export LD=$PATH_TO_BUILDROOT/build_i586/staging_dir/usr/bin/i586-linux-ld
 export CPPFLAGS=-I$PATH_TO_BUILDROOT/build_i586/staging_dir/usr/include
 export LDFLAGS=-L$PATH_TO_BUILDROOT/build_i586/staging_dir/usr/lib
 export PATH=$PATH:$PATH_TO_BUILDROOT/build_i586/staging_dir/usr/bin

 $CC -v -g pthread_test.c -o pthread_test -lpthread
Using built-in specs.
Target: i586-linux-uclibc
Configured with: /home/henry/src/buildroot/toolchain_build_i586/gcc-4.2.1/configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --target=i586-linux-uclibc --enable-languages=c --with-sysroot=/home/henry/src/buildroot/build_i586/staging_dir --with-build-time-tools=/home/henry/src/buildroot/build_i586/staging_dir/usr/i586-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --enable-shared --with-gmp=/home/henry/src/buildroot/toolchain_build_i586/gmp --with-mpfr=/home/henry/src/buildroot/toolchain_build_i586/mpfr --disable-nls --enable-threads --disable-multilib --with-arch=i586 --with-tune=i586
Thread model: posix
gcc version 4.2.1
 /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../libexec/gcc/i586-linux-uclibc/4.2.1/cc1 -quiet -v -iprefix /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/ pthread_test.c -quiet -dumpbase pthread_test.c -mtune=i586 -march=i586 -auxbase pthread_test -g -version -o /tmp/ccwFTh8e.s
ignoring nonexistent directory "/home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/../../../../i586-linux-uclibc/include"
ignoring nonexistent directory "/home/henry/src/buildroot/build_i586/staging_dir/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/i586-linux-uclibc/4.2.1/include"
ignoring nonexistent directory "/usr/lib/gcc/../../i586-linux-uclibc/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/include
 /home/henry/src/buildroot/build_i586/staging_dir/usr/include
End of search list.
GNU C version 4.2.1 (i586-linux-uclibc)
        compiled by GNU C version 4.1.2 20070925 (Red Hat 4.1.2-33).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 0b1243d340343a65a3d063f8a78be63e
 /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/../../../../i586-linux-uclibc/bin/as -V -Qy -o /tmp/ccY3B3Jo.o /tmp/ccwFTh8e.s
GNU assembler version 2.18 (i586-linux-uclibc) using BFD version (GNU Binutils) 2.18
 /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../libexec/gcc/i586-linux-uclibc/4.2.1/collect2 --sysroot=/home/henry/src/buildroot/build_i586/staging_dir --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-uClibc.so.0 -o pthread_test /home/henry/src/buildroot/build_i586/staging_dir/usr/lib/crt1.o /home/henry/src/buildroot/build_i586/staging_dir/usr/lib/crti.o /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/crtbegin.o -L/home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1 -L/home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc -L/home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/../../../../i586-linux-uclibc/lib -L/home/henry/src/buildroot/build_i586/staging_dir/lib -L/home/henry/src/buildroot/build_i586/staging_dir/usr/lib /tmp/ccY3B3Jo.o -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /home/henry/src/buildroot/build_i586/staging_dir/usr/bin/../lib/gcc/i586-linux-uclibc/4.2.1/crtend.o /home/henry/src/buildroot/build_i586/staging_dir/usr/lib/crtn.o


GDB session on the target:

gdb /usr/bin/pthread_test
GNU gdb 6.6
Copyright (C) 2006 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 "i586-linux-uclibc"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run
Starting program: /usr/bin/pthread_test
[Thread debugging using libthread_db enabled]
[New Thread 1024 (LWP 796)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 796)]
0xb7ed14ea in memcpy () from /lib/libc.so.0
(gdb) bt
0 0xb7ed14ea in memcpy () from /lib/libc.so.0
0000001 0xb7edd28c in __libc_pthread_init () from /lib/libc.so.0
2 0xb7eed75c in __pthread_initialize_minimal () from /lib/libpthread.so.0
0000003 0xb7edd381 in __uClibc_init () from /lib/libc.so.0
0000004 0xb7f01393 in _dl_get_ready_to_run () from /lib/ld-uClibc.so.0
0000005 0xb7f016a0 in ?? () from /lib/ld-uClibc.so.0
0000006 0xbfa93490 in ?? ()
0000007 0xb7efe000 in ?? ()
0000008 0xbfa93574 in ?? ()
0000009 0xbfa9360c in ?? ()
0000010 0xbfa93604 in ?? ()
0000011 0xbfa93574 in ?? ()
0000012 0xb7efe000 in ?? ()
0000013 0x00000002 in ?? ()
0000014 0x00000000 in ?? ()
(gdb) q


Also tested this with hello.c:

#include <stdio.h>
#include <stdlib.h>


int main(int argc, char *argv[]) {

  printf("Hello World!\n");

}

This segfaults (same as pthread_test) if -lpthread is used, but works fine without.

Attached Files  pthread_test.c [^] (877 bytes) 04-04-08 12:08

- Relationships
duplicate of 0002264feedback uClibc pthread issues with 0.9.29 

- Notes
(0006974)
carmelo73
04-22-08 08:23

Please, specify which libpthread implementation you are using
(old or new linuxthreads) ?
 
(0007054)
hank_le
04-24-08 11:07

Linking to libpthread causes segfaults using NPTL and linuxthreads (new), but no problems using linuxthreads (old).
 
(0007104)
carmelo73
04-24-08 22:23

There is not NPTL implementation for x86, so how can you link against it ?
it doesn't make sense.
Trying using a freshen version to see if the fix in linuxthreads suggested by Will (that I applied) works or not.
 
(0007284)
hank_le
04-28-08 13:19
edited on: 04-28-08 13:32

I grabbed a buildroot snapshot from 2008-04-25 and rebuilt everything using my oritional .config (uClibc-0.9.29, NPTL/linuxthreads,gcc-4.2.1, binutils-2.18) and my pthread_test.c still segfaults. I need to re-verify all the versions to be sure.

BTW, for my x86 target, I "chose" NPTL in the menuconfig, but it seems that linuxthreads is actually used (a little misleading). Sorry for the confusion.

 
(0007304)
hank_le
04-29-08 06:59
edited on: 04-29-08 07:01

Ok, I grabbed the latest buildroot snapshot (20080429), and configured for uClibc-snapshot, linuxthreads,gcc-4.2.1, andbinutils-2.18. The build gets as far as gcc, and I get the following error (apparently it can't find pthread.h):

make[2]: Entering directory `/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1-initial/gcc'
/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1-initial/./gcc/xgcc -B/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1-initial/./gcc/ -B/home/leinhos/src/buildroot-20080429/build_i586/staging_dir/usr/i586-linux-uclibc/bin/ -B/home/leinhos/src/buildroot-20080429/build_i586/staging_dir/usr/i586-linux-uclibc/lib/ -isystem /home/leinhos/src/buildroot-20080429/build_i586/staging_dir/usr/i586-linux-uclibc/include -isystem /home/leinhos/src/buildroot-20080429/build_i586/staging_dir/usr/i586-linux-uclibc/sys-include -O2 -g -Os -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -I. -I. -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/. -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/../include -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/../libcpp/include -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gmp/include -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/mpfr/include -I/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/../libdecnumber -I../libdecnumber -g0 -finhibit-size-directive -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-omit-frame-pointer \
  -c /home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/crtstuff.c -DCRT_BEGIN \
  -o crtbegin.o
In file included from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/bits/uClibc_stdio.h:119,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/stdio.h:72,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/tsystem.h:90,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/crtstuff.c:68:
/home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/bits/uClibc_mutex.h:15:21: error: pthread.h: No such file or directory
In file included from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/bits/uClibc_mutex.h:16,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/bits/uClibc_stdio.h:119,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/stdio.h:72,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/tsystem.h:90,
                 from /home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1/gcc/crtstuff.c:68:
/home/leinhos/src/buildroot-20080429/toolchain_build_i586/uClibc_dev//usr/include/bits/uClibc_pthread.h:27:3: error: #error "Always include <pthread.h> rather than <bits/uClibc_pthread.h>"
make[2]: *** [crtbegin.o] Error 1
make[2]: Leaving directory `/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1-initial/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1-initial'
make: *** [/home/leinhos/src/buildroot-20080429/toolchain_build_i586/gcc-4.2.1-initial/.compiled] Error 2

 
(0007314)
hank_le
04-29-08 08:44

ok,

I backed off on the gcc version (4.1.2), took the uClibc snapshot from a couple days ago (20080425), and got past the __libc_pthread_init() call, but eventually segfaults during thread cleanup (_pthread_cleanup_pop_restore@plt). This is from my gdb session on the target:

# gdb pthread_test
GNU gdb 6.6
Copyright (C) 2006 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 "i586-linux-uclibc"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) r
Starting program: /tmp/pthread_test
[Thread debugging using libthread_db enabled]
[New Thread 1024 (LWP 853)]
creating thread
[New Thread 2049 (LWP 856)]
[New Thread 1026 (LWP 857)]
[Thread 1026 (LWP 857) exited]
[Thread 1024 (LWP 853) exited]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 853)]
0xb7f8dfb0 in _pthread_cleanup_pop_restore@plt () from /lib/libc.so.0
(gdb) bt
0 0xb7f8dfb0 in _pthread_cleanup_pop_restore@plt () from /lib/libc.so.0
0000001 0xb7fb096c in exit () from /lib/libc.so.0
2 0xb7fc998f in __pthread_do_exit () from /lib/libpthread.so.0
0000003 0xb7fc99b2 in pthread_exit () from /lib/libpthread.so.0
0000004 0x08048745 in main () at pthread_test.c:40
(gdb)
 

- Issue History
Date Modified Username Field Change
04-04-08 12:08 hank_le New Issue
04-04-08 12:08 hank_le Status new => assigned
04-04-08 12:08 hank_le Assigned To  => uClibc
04-04-08 12:08 hank_le File Added: pthread_test.c
04-19-08 23:00 carmelo73 Relationship added duplicate of 0002264
04-22-08 08:23 carmelo73 Note Added: 0006974
04-24-08 11:07 hank_le Note Added: 0007054
04-24-08 22:23 carmelo73 Note Added: 0007104
04-24-08 22:29 carmelo73 Status assigned => feedback
04-28-08 13:19 hank_le Note Added: 0007284
04-28-08 13:32 hank_le Note Edited: 0007284
04-29-08 06:59 hank_le Note Added: 0007304
04-29-08 07:00 hank_le Note Edited: 0007304
04-29-08 07:01 hank_le Note Edited: 0007304
04-29-08 08:44 hank_le Note Added: 0007314


Copyright © 2000 - 2006 Mantis Group
Powered by Mantis Bugtracker