From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1EDBA3857819; Mon, 13 Sep 2021 08:25:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EDBA3857819 From: "nsz at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug dynamic-link/19329] dl-tls.c assert failure at concurrent pthread_create and dlopen Date: Mon, 13 Sep 2021 08:25:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.22 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nsz at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: nszabolcs at gmail dot com X-Bugzilla-Target-Milestone: 2.34 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 08:25:16 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D19329 --- Comment #40 from Szabolcs Nagy --- (In reply to xujing from comment #39) > I'm sorry, I misled you. I think there is an ABBA deadlock issue in some > scenarios. >=20 > 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 th= at > two threads execute the following process=EF=BC=9A > Thread1:dlopen(libA.so) =3D> hold dl_load_lock =3D> load libA.so =3D>= init > global=20 > object from libA.so =3D> wait for hold A_lock > Thread2:my own code hold A_lock =3D> pthread_create =3D> > _dl_allocate_tls_init=20 > =3D> wait for hold dl_load_lock > In this case, an ABBA deadlock occurs. Is this a bug? yes i think this should work (it is a lock ordering issue between a user and libc internal lock, which is only possible if user code is run while a libc lock is held) note that if you replace pthread_create with dlopen that deadlocks too. so it's still bug 15686. but it may be more common than i expected. i think we need to look at fixing that bug. (fixing the dynamic tls race of this bug without locks in pthread_create is very hard, so i don't think we can revert the quoted patch) --=20 You are receiving this mail because: You are on the CC list for the bug.=