OSDN Git Service

synchronize shared library dtor exec against concurrent loads/ctors
authorRich Felker <dalias@aerifal.cx>
Sat, 2 Mar 2019 03:47:29 +0000 (22:47 -0500)
committerRich Felker <dalias@aerifal.cx>
Sun, 3 Mar 2019 17:06:44 +0000 (12:06 -0500)
commit8e43b5613eea0b557a2e91368917a90f4b0e4ab2
treeba010ea02c324ef7363005e8def822fff6aaae09
parent188759bbee057aa94db2bbb7cf7f5855f3b9ab53
synchronize shared library dtor exec against concurrent loads/ctors

previously, going way back, there was simply no synchronization here.
a call to exit concurrent with ctor execution from dlopen could cause
a dtor to execute concurrently with its corresponding ctor, or could
cause dtors for newly-constructed libraries to be skipped.

introduce a shutting_down state that blocks further ctor execution,
producing the quiescence the dtor execution loop needs to ensure any
kind of consistency, and that blocks further calls to dlopen so that a
call into dlopen from a dtor cannot deadlock.

better approaches to some of this may be possible, but the changes
here at least make things safe.
ldso/dynlink.c