mailing list of musl libc
 help / color / mirror / code / Atom feed
* dlopen deadlock
@ 2016-01-13 11:09 Szabolcs Nagy
  2016-01-14 22:41 ` Rich Felker
  0 siblings, 1 reply; 8+ messages in thread
From: Szabolcs Nagy @ 2016-01-13 11:09 UTC (permalink / raw)
  To: musl

This bug i reported against glibc also affects musl:
https://sourceware.org/bugzilla/show_bug.cgi?id=19448

in case of musl it's not the global load lock, but the
init_fini_lock that causes the problem.

the multi-threadedness detection is also problematic in
do_init_fini:

	need_locking = has_threads
	if (need_locking)
		lock(init_fini_lock)
	for all deps
		run_ctors(dep)
		if (!need_locking && has_threads)
			need_locking = 1
			lock(init_fini_lock)
	if (need_locking)
		unlock(init_fini_lock)

checking for threads after ctors are run is too late if
the ctors may start new threads that can dlopen libs with
common deps with the currently loaded lib.

one solution i can think of is to have an init_fini_lock
for each dso, then the deadlock only happens if a ctor
tries to dlopen its own lib (directly or indirectly)
which is nonsense (the library depends on itself being
loaded)

(in glibc with a self-loading ctor in the same thread the
second dlopen succeeds even though the ctors haven't finished
running, not sure if that's better than deadlock, in any case
running user code from libc is problematic, ctors vs dlopen
seems to be a disaster)


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-03-23 10:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 11:09 dlopen deadlock Szabolcs Nagy
2016-01-14 22:41 ` Rich Felker
2016-01-15  0:31   ` Szabolcs Nagy
2016-01-15  2:47     ` Rich Felker
2016-01-15  4:59       ` Rich Felker
2016-01-15 10:58       ` Szabolcs Nagy
2016-01-15 19:16         ` Rich Felker
2016-03-23 10:55     ` Szabolcs Nagy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).