pthread_mutex_lock and pthread_mutex_unlock
Paul Floyd
pjfloyd at wanadoo.fr
Thu Jan 15 04:43:33 PST 2026
Hi
I just noticed that if I put breakpoints on pthread_mutex_lock and
pthread_mutex_unlock in gdb141 then I don't hit the lock breakpoint
until I reach main().
However if I set a breakpoint on _pthread_mutex_lock (with a leading
underscore) then I stop at
Breakpoint 1.1, 0x00000008006e4ca1in _pthread_mutex_lock() from
/usr/lib/libpthread.so.0
(gdb) bt
#0 0x00000008006e4ca1in _pthread_mutex_lock() from /usr/lib/libpthread.so.0
#1 0x00000008006ddc53in pthread_once() from /usr/lib/libpthread.so.0
#2 0x0000000800955b76in ??() from /lib/libc.so.8
#3 0x000000080094d406in _libc_thr_init() from /lib/libc.so.8
#4 0x00000008006e56e1in _thread_init() from /usr/lib/libpthread.so.0
#5 0x0000000800405f8ein ??() from /libexec/ld-elf.so.2
#6 0x0000000800408ca5in _rtld_call_init() from /libexec/ld-elf.so.2
#7 0x00000000004008d2in _start()
in the ld.so code.
Can anyone explain what is going on?
My guess that _pthread_mutex_lock() is some safe version that can be
called from ld.so (and that unlock is always safe). Then after ld.so has
initialised user code can use pthread_mutex_lock().
Are there any other functions that do this?
Regards
Paul
More information about the Users
mailing list