Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#5600 closed bug (invalid)

pthread_self() sometimes returns NULL

Reported by: kaliber Owned by: bonefish
Priority: normal Milestone: R1
Component: System/runtime_loader Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Following issue is very odd. I have a gcc4 binary called metacity which uses glib with pthreads. Sometimes pthread_self() returns NULL and metacity crashes. When I run metacity with LD_PRELOAD=any_existing_library_or_binary then it works.

Debug code in glib (gthread) library:

fprintf(stderr, "pthread_self(): %p\n", pthread_self());
~> metacity
pthread_self(): (nil)
Kill Thread
~> LD_PRELOAD=/bin/ls metacity
pthread_self(): 0x323ee0
Window manager error: Unable to open X display
~> LD_PRELOAD=libroot.so metacity
pthread_self(): 0x2fdee0
Window manager error: Unable to open X display

Change History (2)

comment:1 by bonefish, 14 years ago

Resolution: invalid
Status: newclosed

libroot's pthread_self() implementation cannot return NULL. I've also verified that this is the case for the disassembled gcc4 code. My guess is that some library (some of glib libs?) also exports a pthread_self(). That would also explain why pre-loading libroot.so or anything that links against it fixes the issue, since that puts libroot.so earlier in the global shared object list, so that its pthread_self() is found when the symbol is search.

Note that whatever library is responsible might rely on weak symbols being supported, which is not the case for Haiku yet. Maybe the library is just not configured correctly.

comment:2 by kaliber, 14 years ago

Thank you very much for your help. The bug was in the libX11 library. I fixed it here: http://svn.gna.org/viewcvs/pingwinek/trunk/packages/libx11/libx11-haiku.patch?rev=13637&view=auto

Note: See TracTickets for help on using tickets.