[v7,0/4] elf: Release dl_load_lock around ELF constructors and destructors + LD_DEBUG=loadlock observability (BZ 15686)
| Message ID | 20260803200326.477666-1-temap@mail.ru (mailing list archive) |
|---|---|
| Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6CD0D4BB3BAC for <patchwork@sourceware.org>; Mon, 3 Aug 2026 20:04:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CD0D4BB3BAC Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=mail.ru header.i=@mail.ru header.a=rsa-sha256 header.s=mail4 header.b=CmjQjne1 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from send174.i.mail.ru (send174.i.mail.ru [95.163.59.13]) by sourceware.org (Postfix) with ESMTPS id 913674BA9003 for <libc-alpha@sourceware.org>; Mon, 3 Aug 2026 20:03:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 913674BA9003 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=mail.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mail.ru ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 913674BA9003 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=95.163.59.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785787421; cv=none; b=SrI1CSaTiBh2fBHWtiU8EXS7R5eVq3Tqu6iQlhnkRQyLvck94UfR724bp16uyxQs3h1OnhOjuCnwO/WsJ57jhfUW+HQ2t1yG1ER3B8FzrzI/ElN+26jOMWpOJ3HZtow+2bWZ+6jfFoegG06YIpta+SlhWIme+R/3EEp3HjLwJRw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785787421; c=relaxed/simple; bh=4fNbE5L0t0PxcCZPrG3mEXpn1AvQ8QO2IOOOyjXWnE8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=qsxZl1+hW9l9uD2trq68XDLkKgqU6MuxRvD76NZ5bWMmO+R/X7Whk302BocIvWtIb6HOqUhP46T3hjrt00s+fsSZt0KcjwUsjFDMELaT2fDeu4Kz7U2MWujNwZeDI8cvKdwecDJDbs+b0P3ziqYeN39+vipT87HPEyQkzaAAs/8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=mail.ru header.i=@mail.ru header.a=rsa-sha256 header.s=mail4 header.b=CmjQjne1 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 913674BA9003 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail4; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:From:Sender:Reply-To:To:Cc:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive: X-Cloud-Ids:Disposition-Notification-To; bh=WfGjhTcradAJ1EhwmXtD9CySZO0irylcO8/88E10+o0=; t=1785787421; x=1785877421; b=CmjQjne1k3Xbe1g0/o0xqvh/akuNEuSAJjw82NR/eTBsUUVLiWUVJVseP76FGzjrND8R1y/0O9U UPx2SO8u8TESd1gwIIyB5vGqbeYSiGFtnwkjmGkVgTziUyIe24+U8xFYoGQzsAWHUv6O4pcLllEoF lAjbZiJpDvfdXxXkCQ4QSPYFS7riyFbLHTA35iOZ05XC5nbquh7OwFyrARQ6wl8nbvPlI6H8TMEDQ FcV8cSAift7ngNO9M6i+UWVp5otGQ0diIMFHRG2vs6G/j7m2hjOCvLmHA9HuWjYHHKde1nTE2ZtJv 8aOsL4ZeHLzlwtT+v77CFjquYkLkq//Txfwg==; Received: by exim-smtp-7f4897b4d8-jnp6d with esmtpa (envelope-from <temap@mail.ru>) id 1wqyst-00000000ODN-0aiE; Mon, 03 Aug 2026 23:03:39 +0300 From: temap@mail.ru To: libc-alpha@sourceware.org Cc: fweimer@redhat.com, carlos@redhat.com, adhemerval.zanella@linaro.org, pzz@apevzner.com, m.novosyolov@rosa.ru, Artem Proskurnev <temap@mail.ru> Subject: [PATCH v7 0/4] elf: Release dl_load_lock around ELF constructors and destructors + LD_DEBUG=loadlock observability (BZ 15686) Date: Mon, 3 Aug 2026 23:03:22 +0300 Message-ID: <20260803200326.477666-1-temap@mail.ru> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260801074707.2565716-1-temap@mail.ru> References: <20260801074707.2565716-1-temap@mail.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: exim-smtp-7f4897b4d8-jnp6d; auth=pass smtp.auth=temap@mail.ru smtp.mailfrom=temap@mail.ru X-Mailru-Src: smtp X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9DFD0580A18F85590776127640D954392C793199563D63247182A05F538085040CB0D782FCB6E0B723DE06ABAFEAF67050A8673637499CFC960A95275554C5115033BD305FDD3E522 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71C9A87BC3B243991EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB553375665029C9298A93E94D0533867ECEA18295D2DC56DD8BB9F3EB4D9D36CC745EBF998EEF46B7454FC60B9742502CCDD46D0DEDCF5861DED71B2F389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C02F11D39E7306DD338941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B66EA1BA7CA28B4A74CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C224916AF30C9F9385CF076E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8BD19C4ED1728F8E7A3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735C96613F75B7D048DC4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A516F3C6ACD01FC9AA5002B1117B3ED696AD7DA84FA573B954E772F934B9BCD185823CB91A9FED034534781492E4B8EEAD2F8D89FC5850081EC79554A2A72441328621D336A7BC284946AD531847A6065A17B107DEF921CE79BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F9677DD89D51EBB774225B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659395D5DD7F84FCFB5025FA5931D0F5F8EAA433024D5D1EE6042BA91556983994A6787BB25048117C0B8341EE9D5BE9A0AE07F0404D7A520EA248AF0251BFDC22DBE7A72E16232326EDABE3362BFED2FD64C41F94D744909CE8FFD5CA72B28909428BE7793689043A537E69C174A41D00C X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVYrk7BQKFwEt7pUaW8IEKm/23p9K1t2tOA== X-Mailru-Sender: 583F1D7ACE8F49BDC25C0C59A06B2F96BF976004B4B60652B951B70A5BD4BD8E73244285A423506A658FF8A01747BD16981BBF36307557118FCA44E9AC9C8EC2EEE2A91DED5447003DDE9B364B0DF289AE208404248635DF X-Mras: Ok X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
elf: Release dl_load_lock around ELF constructors and destructors + LD_DEBUG=loadlock observability (BZ 15686)
|
|
Message
Artem Proskurnev
Aug. 3, 2026, 8:03 p.m. UTC
From: Artem Proskurnev <temap@mail.ru>
This v6 series implements the three concrete asks from Carlos's
2026-07-21 review of v3 ("Re: [PATCH v3] elf: Release dl_load_lock
before running dlopen constructors (BZ 15686)"):
(a) Keep the glibc.rtld.strict_init_order tunable, document it, and
flag it for eventual removal once the ecosystem has been shown
to work with the new default. Carlos on (3) in that message:
"I think it's OK to keep the tunable ... The documentation
should clearly state we intend to remove this when the
ecosystem has been shown to work with the new implementation."
(b) Extend the same dl_load_lock release to ELF destructors so the
dlclose path mirrors the dlopen path. Carlos on (4): "I'm also
concerned about destructors since both see this kind of problem.
What prevents us from providing the same invariant in
destructors?"
(c) Add an LD_DEBUG option that logs every dl_load_lock acquisition
and release site with a raw-address backtrace, so residual
deadlocks of this shape can be localised without a debugger.
Carlos on tooling: "I think we should add this as a 2/2 patch,
which improves the observability." Then in reply to my
question about how admins know to flip the tunable: "How does
a system admin, or developer know to flip the tunable?" -- the
LD_DEBUG=loadlock trace is the answer.
Patch layout:
0001 - Release dl_load_lock before running dlopen constructors
(BZ 15686). Constructor side. Adds the
glibc.rtld.strict_init_order tunable (documented in
manual/tunables.texi, marked for eventual removal), the
l_init_once / l_init_owner / l_init_pending fields on
struct link_map, and tst-create2..6 covering the ctor
deadlock and concurrent-dlopen races. tst-create4 was
reworked in v7: the old test (flaky probabilistic interleave
check, marked XFAIL) is replaced by a deterministic
barrier-based test that verifies a long-running constructor
does not block concurrent dlopen of an unrelated library --
the core invariant the BZ 15686 fix provides.
0002 - Release dl_load_lock before running dlclose destructors
(BZ 15686). Destructor side; same tunable, same caveat.
Mirrors the _dl_fini behaviour on the _dl_close_worker
path. Adds tst-create7..10 covering the symmetric dtor
scenarios.
0003 - Add LD_DEBUG=loadlock to trace dl_load_lock acquisitions
(BZ 15686). Instruments the dlopen constructor path. The
backtrace is a manual frame-pointer walk -- deliberately
lock-free, allocation-free and syscall-free, so the trace
can be emitted while dl_load_lock is held without
re-entering the loader. Raw addresses are resolved offline
with addr2line(1).
0004 - Add LD_DEBUG=loadlock tracing for the dlclose destructor
path (BZ 15686). Extends 0003 coverage to _dl_close and
_dl_close_worker, including the BZ 15686 release site
around _dl_call_fini.
The scope claim made in v3 (originally independent threads can run
independent dlopens concurrently; a constructor or destructor may
call any libc / dynamic-loader function safe to call from a regular
non-signal-handler thread) now applies symmetrically to constructors
and destructors. Synchronous loader-internal reentrancy (e.g. a
malloc interposer that itself calls dlopen, routing through the
loader's own malloc during dlopen processing outside the ctor/dtor
window) remains out of scope, as in v3.
Testing: x86_64 make check across five trees (unpatched, +0001,
+0001+0002, +0001..+0003, +0001..+0004) with the same tst-create1..10
regression suite forward-ported onto each tree. Each functional
patch converts exactly one tst-create* timeout-on-deadlock into a
PASS with no other transitions; 0003 and 0004 each add one PASS
(elf/tst-debug-loadlock) for the LD_DEBUG=loadlock test and are
otherwise pure diagnostics with no behavioural diff. tst-create4
(barrier-based deterministic test) passes on all five trees
confirming the lock release is effective; no XFAIL marker needed.
The tunable is expected to remain in tree for roughly four release
cycles, per Carlos's guidance, and is removed once the ecosystem
has been shown to adapt.
Artem Proskurnev (4):
elf: Release dl_load_lock before running dlopen constructors (BZ
15686)
elf: Release dl_load_lock before running dlclose destructors (BZ
15686)
elf: Add LD_DEBUG=loadlock to trace dl_load_lock acquisitions (BZ
15686)
elf: Add LD_DEBUG=loadlock tracing for the dlclose destructor path (BZ
15686)
elf/Makefile | 5 +
elf/dl-close.c | 87 ++++++++++++++--
elf/dl-debug.c | 42 ++++++++
elf/dl-init.c | 99 +++++++++++++++++-
elf/dl-open.c | 161 ++++++++++++++++++++++++++++-
elf/dl-tunables.list | 6 ++
elf/rtld.c | 2 +
elf/tst-debug-loadlock-mod.c | 4 +
elf/tst-debug-loadlock.c | 131 +++++++++++++++++++++++
elf/tst-rtld-list-tunables.exp | 1 +
include/link.h | 22 ++++
manual/dynlink.texi | 12 +++
manual/tunables.texi | 46 +++++++++
sysdeps/generic/ldsodefs.h | 12 +++
sysdeps/pthread/Makefile | 104 +++++++++++++++++++
sysdeps/pthread/tst-create10.c | 119 +++++++++++++++++++++
sysdeps/pthread/tst-create10mod.c | 59 +++++++++++
sysdeps/pthread/tst-create2.c | 67 ++++++++++++
sysdeps/pthread/tst-create2mod.c | 74 +++++++++++++
sysdeps/pthread/tst-create3.c | 112 ++++++++++++++++++++
sysdeps/pthread/tst-create3.h | 27 +++++
sysdeps/pthread/tst-create3mod.c | 68 ++++++++++++
sysdeps/pthread/tst-create4.c | 100 ++++++++++++++++++
sysdeps/pthread/tst-create4.h | 37 +++++++
sysdeps/pthread/tst-create4mod-a.c | 30 ++++++
sysdeps/pthread/tst-create4mod-b.c | 22 ++++
sysdeps/pthread/tst-create5.c | 63 +++++++++++
sysdeps/pthread/tst-create6.c | 111 ++++++++++++++++++++
sysdeps/pthread/tst-create6.h | 26 +++++
sysdeps/pthread/tst-create6mod.c | 72 +++++++++++++
sysdeps/pthread/tst-create7.c | 129 +++++++++++++++++++++++
sysdeps/pthread/tst-create7mod-a.c | 46 +++++++++
sysdeps/pthread/tst-create7mod-b.c | 26 +++++
sysdeps/pthread/tst-create8.c | 97 +++++++++++++++++
sysdeps/pthread/tst-create8mod-a.c | 55 ++++++++++
sysdeps/pthread/tst-create8mod-b.c | 27 +++++
sysdeps/pthread/tst-create9.c | 113 ++++++++++++++++++++
sysdeps/pthread/tst-create9mod.c | 37 +++++++
38 files changed, 2239 insertions(+), 12 deletions(-)
create mode 100644 elf/tst-debug-loadlock-mod.c
create mode 100644 elf/tst-debug-loadlock.c
create mode 100644 sysdeps/pthread/tst-create10.c
create mode 100644 sysdeps/pthread/tst-create10mod.c
create mode 100644 sysdeps/pthread/tst-create2.c
create mode 100644 sysdeps/pthread/tst-create2mod.c
create mode 100644 sysdeps/pthread/tst-create3.c
create mode 100644 sysdeps/pthread/tst-create3.h
create mode 100644 sysdeps/pthread/tst-create3mod.c
create mode 100644 sysdeps/pthread/tst-create4.c
create mode 100644 sysdeps/pthread/tst-create4.h
create mode 100644 sysdeps/pthread/tst-create4mod-a.c
create mode 100644 sysdeps/pthread/tst-create4mod-b.c
create mode 100644 sysdeps/pthread/tst-create5.c
create mode 100644 sysdeps/pthread/tst-create6.c
create mode 100644 sysdeps/pthread/tst-create6.h
create mode 100644 sysdeps/pthread/tst-create6mod.c
create mode 100644 sysdeps/pthread/tst-create7.c
create mode 100644 sysdeps/pthread/tst-create7mod-a.c
create mode 100644 sysdeps/pthread/tst-create7mod-b.c
create mode 100644 sysdeps/pthread/tst-create8.c
create mode 100644 sysdeps/pthread/tst-create8mod-a.c
create mode 100644 sysdeps/pthread/tst-create8mod-b.c
create mode 100644 sysdeps/pthread/tst-create9.c
create mode 100644 sysdeps/pthread/tst-create9mod.c