From nobody Fri May 19 11:24:49 2023 X-Original-To: threads@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QN4J12Zrmz4BqVc for ; Fri, 19 May 2023 11:24:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QN4J11ZXzz4VxS for ; Fri, 19 May 2023 11:24:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684495489; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=didJ2D+kFiCy0e8LSdsbFOKnIOptyIoFkzNlZCa4WXI=; b=TsfcnYCraYbqCktzvQRJLYlt1y/dBo2FbeHcCKx6SbdYxWlFoiwNOIGURQvPCHsBbid/TV g7jZs53M+gNaQ0kc8rYuAAd5ZFzjj6YEpMzy4/3TYFZJHC45B8SdaqFcSoMT2uNghslCnV tXHjHJl6Hz7JU3jb8rOa0UBbqQ3Lwzspvp2wvUlcrnkSWgfP4mezXZSQWnSQli+knmj9XZ FqBEp7uUGnXhholD/tVIaglpu9kQVC35Jxhhf5xBdNVozbT2xoAlj98XT/bRg7SB1Fv+jz Mn8fhGLNWNxYmkiE91e8Mf5HeRsj9X5zKGMFs9WwzputhQ1whKd1zBnfhwboXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684495489; a=rsa-sha256; cv=none; b=hmL+Uz+8T3Q2UkkYuSSccelbG80j175ioAVc0guKwqyjjjz41bGo80dCoYsLq+kmAsxMvG I7UhIAGdzSB3kO9eeM9KLDwfrYmBgiqsrle/tOjLhsxNw4yroQSIO22fQWrImURatBqzvl MJR0mCv4ZaiFLQvx5N0NGgjy13dud4jzUDd6S7KQ5QMsR0c74TnkX1xfIorFGWiINpP2eN DIhliwK1CYJgFs0gO0huL8s8MQ7SH3OGDqF9CD/I51pWQbgahW2bFpTFkd8LHrgBdK8Uzy OTuLp3+F2N1jukjvKuPrV+z6kTMo2MMINIDuBA4c2xtlSC7f9KoMdtPYQppt3g== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QN4J10V6YzQk8 for ; Fri, 19 May 2023 11:24:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 34JBOnx7061913 for ; Fri, 19 May 2023 11:24:49 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 34JBOn9O061912 for threads@FreeBSD.org; Fri, 19 May 2023 11:24:49 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: threads@FreeBSD.org Subject: [Bug 271490] Deadlock between _rtld_atfork_pre and _thr_attr_init Date: Fri, 19 May 2023 11:24:49 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: threads X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: kj@kjtsanaktsidis.id.au X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: threads@FreeBSD.org 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: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Threading List-Archive: https://lists.freebsd.org/archives/freebsd-threads List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-threads@freebsd.org X-BeenThere: freebsd-threads@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271490 --- Comment #7 from KJ Tsanaktsidis --- I did make a bit more progress debugging the issue though - I don't think t= he problem has anything to do with jemalloc at all - it's _just_ an RTLD issue. I captured a different backtrace of the problem and attached it. In this one thread #2 is just sitting there chilling on an unrelated mutex; it is _not_ doing any jemalloc things. So, thread #1 manages to get deadlocked during `_rtld_atfork_pre` all by itself. In particular, it's blocked acquiring the `rtld_bind_lock` in write mode, a= nd the lock appears to already be held in write mode (by who??): ``` (gdb) print *((struct rtld_lock *)lock) $21 =3D {lock =3D {rw_state =3D -1610612736, rw_flags =3D 2, rw_blocked_rea= ders =3D 1, rw_blocked_writers =3D 0, rw_spare =3D {0, 0, 0, 0}}, _pad =3D '\000' } # bitmask against URWLOCK constants, from https://github.com/freebsd/freebsd-src/blob/1377eb268a5a8a5573bda33a6519632= 59c43c3ed/sys/sys/umtx.h#L62 (gdb) print /x ((struct rtld_lock *)lock)->lock.rw_state & 0x80000000U $22 =3D 0x80000000 (gdb) print /x ((struct rtld_lock *)lock)->lock.rw_state & 0x40000000U $23 =3D 0x0 (gdb) print /x ((struct rtld_lock *)lock)->lock.rw_state & 0x1FFFFFFFU $24 =3D 0x0 (gdb) ``` Also also, I'm not 100% sure yet that this wasn't just luck so far, but it _seems_ I can avoid the deadlock by setting `LD_BIND_NOW`... Anyway I'll keep hunting for an isolated reproduction. If you have a stab in the dark though I'm happy to try a patch as well. --=20 You are receiving this mail because: You are the assignee for the bug.=