public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug admin/28331] New: Multi-threaded exec pthread_create and dlopen may cause deadlock
@ 2021-09-11 10:35 xujing99 at huawei dot com
2021-09-13 2:59 ` [Bug admin/28331] " xujing99 at huawei dot com
2021-09-13 7:26 ` [Bug dynamic-link/28331] " schwab@linux-m68k.org
0 siblings, 2 replies; 3+ messages in thread
From: xujing99 at huawei dot com @ 2021-09-11 10:35 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=28331
Bug ID: 28331
Summary: Multi-threaded exec pthread_create and dlopen may
cause deadlock
Product: glibc
Version: 2.35
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: admin
Assignee: unassigned at sourceware dot org
Reporter: xujing99 at huawei dot com
CC: carlos at redhat dot com
Target Milestone: ---
after merge commit 1387ad6225c2222f027790e3f460e31aa5dd2c54, multi-threaded
exec pthread_create and dlopen may cause deadlock.
thread1:dlopen hold dl_load_lock and then load a dynamic library which will
hold ACE_lock(defined by my self)
thread2:a program hold ACE_lock and then call
pthread_create=>_dl_allocate_tls_init will hold dlopen dl_load_lock
in this case, it will cause deadlock.
for example:
thread1:dlopen => hold dl_load_lock => spawn_n => wait for hold ACE_lock
thread2:spawn_n => hold ACE_lock => pthread_create => _dl_allocate_tls_init =>
wait for hold dl_load_lock
(spawn_n is my own function)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug admin/28331] Multi-threaded exec pthread_create and dlopen may cause deadlock
2021-09-11 10:35 [Bug admin/28331] New: Multi-threaded exec pthread_create and dlopen may cause deadlock xujing99 at huawei dot com
@ 2021-09-13 2:59 ` xujing99 at huawei dot com
2021-09-13 7:26 ` [Bug dynamic-link/28331] " schwab@linux-m68k.org
1 sibling, 0 replies; 3+ messages in thread
From: xujing99 at huawei dot com @ 2021-09-13 2:59 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=28331
--- Comment #1 from xujing <xujing99 at huawei dot com> ---
If I have a c++ dynamic library(named libA.so) that contains a global object,
the global object will call the post-constructor at initialization and hold
it's own lock(named A_lock) when dlopen loads libA.so. Assume that two threads
execute the following process:
Thread1:dlopen(libA.so) => hold dl_load_lock => load libA.so => init global
object from libA.so => wait for hold A_lock
Thread2:my own code hold A_lock => pthread_create => _dl_allocate_tls_init
=> wait for hold dl_load_lock
In this case, an ABBA deadlock occurs. Is this a bug?
My stack looks like this:
Thread 1 (LWP 136013):
#0 0x00007f57a108510d in ?? () from /usr/lib64/libpthread.so.0
#1 0x00007f57a107e4d1 in pthread_mutex_lock () from /usr/lib64/libpthread.so.0
#1 stack waiting for holding A_lock
...
#6 0x00007f5781c1bb8b in LogProcess::Init (strProcName=...,
nProcHandle=nProcHandle@entry=0) at
./service/biz_frame/code/server/src/logging/logprocess.cpp:107
...
#20 0x00007f57a0fef21f in _dl_catch_exception () from /usr/lib64/libc.so.6
#21 0x00007f57a786442b in ?? () from /lib64/ld-linux-x86-64.so.2
#22 0x00007f57a3de2296 in ?? () from /usr/lib64/libdl.so.2
#23 0x00007f57a0fef21f in _dl_catch_exception () from /usr/lib64/libc.so.6
#24 0x00007f57a0fef2af in _dl_catch_error () from /usr/lib64/libc.so.6
#25 0x00007f57a3de2985 in ?? () from /usr/lib64/libdl.so.2
#26 0x00007f57a3de2351 in dlopen () from /usr/lib64/libdl.so.2
...
...
#38 0x00007f57a0fb3520 in clone () from /usr/lib64/libc.so.6
Thread 2 (LWP 134627):
#0 0x00007f57a108510d in ?? () from /usr/lib64/libpthread.so.0
#1 0x00007f57a107e580 in pthread_mutex_lock () from /usr/lib64/libpthread.so.0
#2 0x00007f57a7863835 in _dl_allocate_tls_init () from
/lib64/ld-linux-x86-64.so.2
#3 0x00007f57a107cb7c in pthread_create () from /usr/lib64/libpthread.so.0
...
#10 Stack holding A_lock
...
#14 0x0000561689e0d579 in main ()
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug dynamic-link/28331] Multi-threaded exec pthread_create and dlopen may cause deadlock
2021-09-11 10:35 [Bug admin/28331] New: Multi-threaded exec pthread_create and dlopen may cause deadlock xujing99 at huawei dot com
2021-09-13 2:59 ` [Bug admin/28331] " xujing99 at huawei dot com
@ 2021-09-13 7:26 ` schwab@linux-m68k.org
1 sibling, 0 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2021-09-13 7:26 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=28331
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|admin |dynamic-link
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-13 7:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-11 10:35 [Bug admin/28331] New: Multi-threaded exec pthread_create and dlopen may cause deadlock xujing99 at huawei dot com
2021-09-13 2:59 ` [Bug admin/28331] " xujing99 at huawei dot com
2021-09-13 7:26 ` [Bug dynamic-link/28331] " schwab@linux-m68k.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).