C++/dlerror/pthread problem
David Mosberger
davidm@napali.hpl.hp.com
Thu Jul 31 16:28:00 GMT 2003
>>>>> On Thu, 31 Jul 2003 16:28:01 +0200, Thorsten Kukuk <kukuk@suse.de> said:
Thorsten> The appended example program works fine, if not linked
Thorsten> against libpthread or if it is compiled as C program. But
Thorsten> as C++ program linked against libpthread, it will
Thorsten> seg.fault in dlerror().
Thorsten> Does somebody know why? I know it is a bad idea to call
Thorsten> dlerror() without any other dl* call before, but people
Thorsten> are doing so ...
Here is a possibility: depending on platform and exact version of
libpthread, here is what happens: you link (and build) against
libpthread, which will give you an "errno" that references a field in
the thread descriptor. But since you never actually do any pthread
calls, the thread descriptor for the main thread never gets set up.
Thus, any attempt to use errno will cause a segfault. This is known
to happen on ia64 with LinuxThreads. NPTL is fine, as far as I know.
--david
More information about the Libc-hacker
mailing list