From nobody Fri May 19 00:40:21 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 4QMp0Q0kxpz4CCqw for ; Fri, 19 May 2023 00:40:22 +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 4QMp0P6nD7z4HHm for ; Fri, 19 May 2023 00:40:21 +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=1684456822; 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=T3Wa47iyydpURx+EZgOJsvREN0PhSP/b3Imy0IR5KWQ=; b=qy66hmmxhA0PZMT1xdLZaxCnGQnfiU4W9eOEhWfear+lphD5HGNprwV0TFBMW7OBCJEpGc 2TucKXFGLpohP8rgY0R1AIId9ywSZkDKU0PF/dtxKDFFebQF0zSbY5uxVsWMDq7fSyKjGG 8f2FYTeX+82yBubQvegNQpEaYUvS2fYLbeBz8XNs+FySyz0KU1VEOcSsQSo5DonMwAJGWQ /jl7siCeP63zIWndiG6EBCAZ/PHlNx7KFGrxgqOzENxotIxYmb/lm9oNWVoi9FwrXsQMR7 95f+QkQNb5sbniZnCa2/i/HRury4ArhguIAaOdSJBLUV8rrJfcO2xLz/EJZ6sA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684456822; a=rsa-sha256; cv=none; b=l7jp2BfG+uBKwkPs/tgmOQgifOI7ZvwAQSbrLNgwytPPGiKyZKkVy9aMfmOxF5eIdpMjfz VYVnqcasrpd3B8f5AGiS9OK/4V4V+mHipkghXgIirlt32XHiappqQuF63FKuAjZHXTps9m 8xzYROMiaUq5/8dAzowTBWr9eqaw0T53fVEuguOQ4YsRbq+YqRmxMZ6QdILDCQyPBWlY5K 9N6hitPdcQ2CgUSLGQZQPKbAVD6/iApv9x/vWFxMGFHtvZ7RdXnzZV2kzWpiaspGLMX//Z K/WvqPzGkF8wKUSI7RF4BZQI6SACHEl72ag524/JYSqN8hp3gyNgvNc5v0VVCA== 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 4QMp0P5ljTz16vP for ; Fri, 19 May 2023 00:40:21 +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 34J0eLNR002495 for ; Fri, 19 May 2023 00:40:21 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 34J0eL2e002494 for threads@FreeBSD.org; Fri, 19 May 2023 00:40:21 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 00:40:21 +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 #2 from KJ Tsanaktsidis --- Thanks for your quick eyes. > It seems that the problem is that malloc_mutex_prefork() from jemalloc/src/mutex.c does not lock _all_ jemall= oc mutexes, in particular, the extent mtx. I guess I could try patching this and see if it makes the deadlocks on my machine go away. I'll give it a go over the weekend and report back! > OTOH, note that after fork(), in multi-threaded process child, only async= -signal safe functions are guaranteed to work. Yeah.... this is unfortunately very common in the Ruby world though, becaus= e of a combination of two things: * Gems (especially gems by monitoring providers like Datadog, Sentry, NewRe= lic, etc) that maintain background threads (to e.g. report metrics & exceptions asynchronously to some central service) * Pre-forking webservers (like Unicorn) are frequently used to get good use= of multi-core machines (since only one Ruby thread can run Ruby code at a time= ). These webservers often load all of an applications gems, and _then_ fork workers, to get good use of shared copy-on-write pages. Most gems that maintain background threads install after_fork hooks to rest= art them when they're used inside preforking webservers. The documentation for fork(2) does say: > The FreeBSD implementation of fork() provides a usable malloc(3), and rtl= d(1) services in the child process. when referring to multi-threaded forks, so I guess _this_ is supposed to wo= rk. I do note however that the man page says nothing about DNS resolution worki= ng in the child of a multithreaded fork :/ but that's a problem for another day (maybe Ruby ensures that the resolver is not in use before forking? I haven= 't looked) --=20 You are receiving this mail because: You are the assignee for the bug.=