Bug 171513
Summary: | static linked program using pthread segfault executing pthread_mutex_init | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Gene Czarcinski <gczarcinski> |
Component: | glibc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED DUPLICATE | QA Contact: | Brian Brock <bbrock> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 4 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2005-10-23 07:06:39 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Gene Czarcinski
2005-10-21 22:42:47 UTC
OK, I have finally determined that the function call to pthread_mutex_init() is not being resolved (it is "call 0x0" in the ddd disassembly) ... yes, I figured out how to get gdb/ddd to work inspite of the "error" ... simply continue. Here is the static link command as original: g++ -Wall -g -O2 -o partimage -static netclient.o imagefile.o misc.o image_net.o buffer.o gui_text.o main.o imginfo.o cbitmap.o interface_base.o interface_newt.o interface_none.o mbr_backup.o -L/usr/local/lib -lslang fs/libfs.a ../shared/libshared.a -lz -lnewt -lbz2 -lpthread /usr/lib/libslang.a /usr/lib/libnewt.a /usr/lib/libdl.a /usr/lib/libpthread.a did not work. I then tried this: g++ -Wall -g -O2 -o partimage -static netclient.o imagefile.o misc.o image_net.o buffer.o gui_text.o main.o imginfo.o cbitmap.o interface_base.o interface_newt.o interface_none.o mbr_backup.o -L/usr/local/lib -lslang fs/libfs.a ../shared/libshared.a -lz -lnewt -lbz2 /usr/lib/libslang.a /usr/lib/libnewt.a /usr/lib/libdl.a /usr/lib/libpthread.a /usr/lib/libpthread_nonshared.a again, it did not work. I then built )compiled) the glibc from the src.rpm and copied glibc-20050524T1606/build-i486-linuxnptl/nptl/pthread_mutex_init.o to the directory with my progam and did this: g++ -Wall -g -O2 -o partimage -static netclient.o imagefile.o misc.o image_net.o buffer.o gui_text.o main.o imginfo.o cbitmap.o interface_base.o interface_newt.o interface_none.o mbr_backup.o pthread_mutex_init.o -L/usr/local/lib -lslang fs/libfs.a ../shared/libshared.a -lz -lnewt -lbz2 /usr/lib/libslang.a /usr/lib/libnewt.a /usr/lib/libdl.a /usr/lib/libpthread.a /usr/lib/libpthread_nonshared.a This worked! The program executed with (apparently) the other ptheread function calls being resolved. Stepping through the programs execution with ddd, this time the call I saw was resolved to "call pthread_mutex_init" rather tha "call 0x0" Now this may have worked but it is not a fix. Any hints as to what I am doing wrong? OK, as an additional test, I hacked up the Makefiles to use /usr/include/linuxthreads headers and /usr/lib/linuxthreads libraries. This works with no problems. Mmmm ... this does appear to be a dup of https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=115157 Since everything seems to work OK using (the old) linuxthreads and it has "#pragma weak" also specified, why does this work and the ntpl does not? *** This bug has been marked as a duplicate of 115157 *** After spending lots of time (about three days) trying to figure out what the pthread (segfault) problem was [it took a while until I understood that the function call had not been resolved when it was statically linked], I find that it was a waste of time [well, I did learn a bit about "weak" linkage]. As I said above, the problem was with statically linked partimage which was statically linked so that I did not need to worry about extra libraries when I ran it under the rescuecd. Well, I need not have worried, the shared linked version runs just fine under the rescuecd ... all the needed libraries (newt, slang, bz2, z, AND pthread) where there. At least not I do not have to wait for Alexandre's fix to work its way into production. |