From nobody Tue Jun 30 16:59:38 2026 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 4gqTs70qmPz6jVm5 for ; Tue, 30 Jun 2026 16:59:39 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gqTs64LQVz3lrV for ; Tue, 30 Jun 2026 16:59:38 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782838778; 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; bh=Ft4Cpgi65/cUooWIClOEmIorW1bthA9WWyVO0j4sDo4=; b=Sav36Lb58bFNaSiU7QJF0hXo2369J8CifiZRMddkMn2moWaOAPvzS9feXfKSmzvqp6a9Ch 3frIM0pMG1VuH2oDzOT/TsVPJhpi0/0mJS2EvdewlNslgHwRCCHLI7mYzs63uJ9NpF1Xfd fplHDNoCrv2XhEzqwRjRjWnudZoFRAkhppSzW4TGMq5h9EhQDCfnP8IMXH8tZecYBb07Fc yWl2xYJ9ptBP7g7yXyrAD5XHSSzLaKrQx4kNbG9B0YlvwPPyzp/YFykju2GvIgViI70Xgv WiI+xbzRLJ6dxZqkffzY+hhF3tXGxlhSeM/5BcgPXpGoHJNuTKwP4mtS2+RrSw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782838778; a=rsa-sha256; cv=none; b=vLVfXOirfy9mEKV6FN7CE2wnA5r/irGpJXYG/ZAA5jx8d0O9WpJMaRi4y4blaHhwL3VhCs tk4u2a7bYqSlQ71VnvTOjtW0X+/OLxDG/++4EowhQnRjR4Rpovz9tr95y7wGSisdofh1EV LKGx1WkfwYMMPV7MHs1dGwerPrd7T5lkrQRtjUvqUVk3Ltwmxu0WX0FQ01XEQewhUiDYYu 59JfOEPHfTyxhJXvSOP1KSeFUCPkbfaMSr9WnNjobma9OHtM+0ykWG6/v1tIJ7ZMdf2Ue1 Yr0nytbTFg1QsfrTew6kV0woOHV7y9NrMlNNroT2NDcZXoPYPzBt8tqCQbqpVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782838778; 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; bh=Ft4Cpgi65/cUooWIClOEmIorW1bthA9WWyVO0j4sDo4=; b=tzL+wmETWQaton9sJBiwZnETu3YmwDVNG/q+uyRGCltwkDtDjCB99N/tNVGGbtfMnzNkDE 3OdEyySbj0INaG8oGLYfoz+nkPEsLNJdq2Xdf81LZATNpvCvi9yS9pNY4IbDEfkZ4zbk5s 1T7mDetwh4G9MJq9k5U5DSGYsNmwpPmVLB5bRWZ/GcghgwbGEwzx6S7mA5ZJYr4oUDR7/n BW7Q1ZXcc8R/WSliCxN0FaH3JQCV0hS9Beiy0dZXFEFRp2KAHmtX0U/tUUpFKdur/mW70q Kf2OfOu3CXSlwRzi24PxiZQtHkPBb/k4mDL/no9r/WGC/sgknTJtHxFK0zoMXQ== 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 4gqTs63RTJzsll for ; Tue, 30 Jun 2026 16:59:38 +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 65UGxcwG072830 for ; Tue, 30 Jun 2026 16:59:38 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 65UGxcpR072829 for threads@FreeBSD.org; Tue, 30 Jun 2026 16:59:38 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 296410] sprintf/vfprintf not thread safe on AArch64 due to localeconv_l using atomic_store_int, with relaxed semantics Date: Tue, 30 Jun 2026 16:59:38 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: threads X-Bugzilla-Version: 14.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: tomas@vondra.me X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: threads@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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: X-BeenThere: freebsd-threads@freebsd.org Sender: owner-freebsd-threads@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D296410 Bug ID: 296410 Summary: sprintf/vfprintf not thread safe on AArch64 due to localeconv_l using atomic_store_int, with relaxed semantics Product: Base System Version: 14.4-RELEASE Hardware: arm64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: threads Assignee: threads@FreeBSD.org Reporter: tomas@vondra.me While running tests (for ECPG in Postgres), we're getting occasional segfau= lts in tests using threads. This seems to affect only the AArch64 machine (whic= h is an rpi5), while the two x86_64 machines don't seem to have this issue. The crashes generally look like this: ------ Program terminated with signal SIGSEGV, Segmentation fault. Address not mapped to object. #0 __vfprintf (fp=3Dfp@entry=3D0x889dab00, locale=3Dlocale@entry=3D0x841df= cf0 <__xlocale_global_locale>, serrno=3D0, fmt0=3Dfmt0@entry=3D0x20087a "Connection: %d", ap=3D...) at /usr/src/lib/libc/stdio/vfprintf.c:477 warning: 477 /usr/src/lib/libc/stdio/vfprintf.c: No such file or directo= ry [Current thread is 1 (LWP 933707)] (gdb) bt #0 __vfprintf (fp=3Dfp@entry=3D0x889dab00, locale=3Dlocale@entry=3D0x841df= cf0 <__xlocale_global_locale>, serrno=3D0, fmt0=3Dfmt0@entry=3D0x20087a "Connection: %d", ap=3D...) at /usr/src/lib/libc/stdio/vfprintf.c:477 #1 0x000000008411d434 in vsprintf_l (locale=3D0x841dfcf0 <__xlocale_global_locale>, ap=3D..., str=3D, fmt=3D) at /usr/src/lib/libc/stdio/vsprintf.c:61 #2 vsprintf (str=3D0x889daefc "", fmt=3D, ap=3D...) at /usr/src/lib/libc/stdio/vsprintf.c:68 #3 0x00000000841123f4 in sprintf (str=3D0x0, str@entry=3D0x889daefc "", fmt=3D0x841dfcf0 <__xlocale_global_locale> "") at /usr/src/lib/libc/stdio/sprintf.c:56 #4 0x0000000000210ed8 in fn (arg=3D0x0) at prep.pgc:39 #5 0x00000000847844fc in thread_start (curthread=3D0x63044546d010) at /usr/src/lib/libthr/thread/thr_create.c:291 #6 0x0000000000000000 in ?? () ------ That is, it's a crash in vfprintf, on this line: decpt_len =3D (decimal_point[1] =3D=3D '\0' ? 1 : strlen(decimal_point)); After investigating a bit, I believe this is due to localeconv_l using atom= ics in relaxed mode when updating the decimal_point: if (atomic_load_acq_int(&loc->numeric_locale_changed) !=3D 0) { ... N_ASSIGN_STR(decimal_point); ... atomic_store_int(&loc->numeric_locale_changed, 0); } On architectures with weakly-ordered memory model (like the AArch64), this means the other threads may see the update to numeric_locale_changed, witho= ut seeing the updated decimal_point pointer. Which leads to the crash. This can be reproduced by a simple program: ------ #include #include void *fn(void *arg) { char buf[128]; for(int i=3D0; i<10000; i++) sprintf(buf, "%d", 1); return NULL; } int main() { pthread_t th[100]; for(int i=3D0; i<100; i++) pthread_create(&th[i], NULL, fn, NULL); for(int i=3D0; i<100; i++) pthread_join(th[i], NULL); return 0; } ------ It's a race condition, so it may not crash. But for me it usually takes only ~10-20 tries to crash with a segfault. I believe the code should use atomic_store_rel_int instead, to get the prop= er memory ordering guarantees. Not just for decimal_point, but for the other fields too. (I haven't looked at other places using the relaxed atomics variants, but there might be more similar bugs there.) In practice, this race condition may be fairly unlikely to hit - the window= is fairly narrow. And it's probably enough for the "main" process to do a sing= le sprintf (which initializes the cache) before starting the threads. Which our tests don't do, but bigger apps probably do. Adding such sprintf call to the reproducer seems to fix it. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Tue Jun 30 23:01:16 2026 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 4gqdtN0jPlz6k5Gy for ; Tue, 30 Jun 2026 23:01:16 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gqdtM74yrz3Kg2 for ; Tue, 30 Jun 2026 23:01:15 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782860476; 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=04gUlPgTNQDfrJH0/Qt/ThbhQ9+DleVuepJCD3RhyzE=; b=mfmln8rEiBTdtZPyAcMfwTxkMHf0sdZVYwd6HUw5+GuJqys2mck/YNbgN6BI3GESI7pBRb i+OGgE1h7Mf1oKLEJiPn9+zYTYF+wmCcM8vnGYC3AuZ08PL9iEOvJvqxFvShbLPHzNKBhh Q3WNWI9VtuXS3bx/X9uJY0YQRFvKIyzo4YSr5TpVggaXNgecdG4+hH48LqSrIJyyyZM7a2 Muv+/LpDCNxci7Kz2tFCQkPXB8S3AWeny7vxQogHRRF6kSXmPNU22bR18ykgZm23t4TwqF SlguDK0KF7aWnDjiLb5VrP8dKacbsvYE+c/XT2+V0CJVQ7P8ofsZS5NBjNkR4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782860476; a=rsa-sha256; cv=none; b=va0KAB1fdkSGVA3PsSfcZWXPqqsrw8cyCOkpFt64/lep1WPRXnTgr+Jzl+rirEIFpo8JcE 1ff//muVSrxp5qDymUFtN7hrCvXRmQF5qhQGJzrt3WODp3hEk8QoOZvvnGq9Egb7Ea267k Q/DNCiUWHmV0xPAsEzWOdqPCA889gYt280jfUXmWcDALmu5d1jWbsrM6Yih+OSsDNqc//N yssCfeA0AcFQZLS/I4D27dOzTE8EEw/pXyaocUXMY39yBO+Syyg0FtUy5cRzuyWKf63Qxm xCK0CDj8MbDjg2w/2mM6OnOlhZpRKxkHcb+lBKV3RtXstSKOxQIYgPPAOYouKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782860476; 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=04gUlPgTNQDfrJH0/Qt/ThbhQ9+DleVuepJCD3RhyzE=; b=Oij7tpwbDpWbKZq7M38uB0m4wYHUK0jLCHA4Jco/LitkQXVbVxceC7dcFpL8Q+5JgE4M6G miK1CCPD0BeoAcd4ifdi1gmSVE3T7ea8m/6kAjxe5iMnLuB9oQ+4d+8pJfSfcl4DUt+A3P +gQRRYuoCFni8Ji+CPWXhtCTfD0E6aAZhaPI8rGCEIjj3/is1+g6tXEd8J+u55YX+KvCJI 70b8Z5SycefwRVRoeoVXgOX2338UhCngK1Ocx4NmGfX6V0Zbu08gPa5DP+T4rl+OkXD7Yq GiVPNdJ2VZAbRMa/cNjCT/xzHzaQ2kCXwtxomRgfiDM5CpDQna3ENuQh/BbEtg== 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 4gqdtM6BBnz14Kq for ; Tue, 30 Jun 2026 23:01:15 +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 65UN1FvF038778 for ; Tue, 30 Jun 2026 23:01:15 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 65UN1Fov038776 for threads@FreeBSD.org; Tue, 30 Jun 2026 23:01:15 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 296410] sprintf/vfprintf not thread safe on AArch64 due to localeconv_l using atomic_store_int, with relaxed semantics Date: Tue, 30 Jun 2026 23:01:16 +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: 14.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: kib@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: threads@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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: X-BeenThere: freebsd-threads@freebsd.org Sender: owner-freebsd-threads@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D296410 Konstantin Belousov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kib@FreeBSD.org --- Comment #1 from Konstantin Belousov --- It is easy to change to store_rel in lib/libc/locale/localeconv.c, but is it enough? Suppose that we did not observed numeric_locale_changed !=3D 0, but did obs= erved new values from some loaded fields. Could this inconsistency cause issues? If yes, we need something like seqlocks, as used by timecounters and filedescriptors. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Wed Jul 1 09:18:36 2026 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 4gqvZh6Qs2z6jtsX for ; Wed, 01 Jul 2026 09:18:36 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gqvZh5gXFz3Yd7 for ; Wed, 01 Jul 2026 09:18:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782897516; 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=lcEZPGvYxUBqhY2nicJFW86ECaSPlqdES/K/Lb1pEPQ=; b=k3zKaTA2AjK5oAaoeSHGPq784jaIEH0gCP5wyfVnBjtEk83hE/kVM1MX9hnpyGZ+917XY2 IbYhCV808kGCjm1UWwjiqdqVecSAmrSzhXHRDqdCs3q9yrMxJZjiYxZLJo5WeeQRIAt5Wj oLa3Gm2HdOl0Q/8mwZA17JaRje7pBimVjdacEK75kNeTK4AZ0qJVPhuNAZv/7SdutfDH/U jkUDOzZv8K1K0HKajwyUKvEIrMMBhnvqvTO0Mh8Vepc+MNNmRwviNAPxV1hWgYCX5MWCTx grJ1V9UWRJAuyxcdvUW+VKtNm6d7mLoAKlmCfzFUf05j11yQlc16ivzO5ULENA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782897516; a=rsa-sha256; cv=none; b=IP4trzWbUCHCP1E62un5Sa6QfeqCcGu7fF5/Dwrhy4Ho2Z6kl+kI7qM0LQEUDG1FPJ1E5V mzQWR9Ih7ZUiBJPrtfvjzXDzS3w49m9iTFgKA8px9gzdUwBMyEIO9apb2inbK1N/IYszRQ Ho1o2T3SuTSp02zgCs44sd3mNY69gclp+6GV127TT1Y3DrIiEHDmw3QAOOx0GOxk3z4g4/ Mc/saYWA9WqUeUaVVmL3JsBHrEBx9z3AmGqaNT7DhACgqJqw2tpPcBxj5GQ1nPLpajNTLj p5WP9iqnQZAC2IUpTEpoRgWGn9emncSx61nGP14qFTmFRqw8vS8IWfCyC16SJQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782897516; 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=lcEZPGvYxUBqhY2nicJFW86ECaSPlqdES/K/Lb1pEPQ=; b=YKcMdWNM/kl8stLL68yhznA35eV7y9M579/1mukWJnfiMQDHcBY3WJq5zuEZ3dXqbcvfcM 6/aHxP7cfJZI9CDsLEDbh0467NNybE88dpFnsVnNC6gKPpQL4tJikIK79CWF/9ZBMkQNCt LXmQMejqfTxdLBX22Pv5UZLyxkYorOeOmUlBd2GEtUOaK3EjMlQmz6W4/ume5FH5E2DyWD ffXrscvUQwKRM2Rs8ow89hmLOPBsLHeBVo63Yj208zTm9pSut2sFYSj+1f01rzdeiyPCGW D4Cno8ld5Lak2ZQKryTB/7zPnlyhVwQb6A6QdoxSm59YcWSXfqouXw2lMDS2Pw== 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 4gqvZh49fyz1MJQ for ; Wed, 01 Jul 2026 09:18:36 +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 6619Iah8035515 for ; Wed, 1 Jul 2026 09:18:36 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 6619IaXn035514 for threads@FreeBSD.org; Wed, 1 Jul 2026 09:18:36 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 296410] sprintf/vfprintf not thread safe on AArch64 due to localeconv_l using atomic_store_int, with relaxed semantics Date: Wed, 01 Jul 2026 09:18:36 +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: 14.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: tomas@vondra.me 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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: X-BeenThere: freebsd-threads@freebsd.org Sender: owner-freebsd-threads@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D296410 --- Comment #2 from Tomas Vondra --- (In reply to Konstantin Belousov from comment #1) I'm not very familiar with how the locales work, but the way I understood localeconv_l is that it rebuilds the cached fields after a change (or on fi= rst access). And I thought maybe it's harmless if two threads rebuilt it concurrently, or something like that. But maybe you're right and after a locale change a thread could see a mix of old and new values for a given locale? I guess that'd mean using atomics for protecting other fields (as implemented here) is not quite sufficient. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Sun Jul 5 03:18:37 2026 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 4gtCPT6DnJz6jcKF for ; Sun, 05 Jul 2026 03:18:37 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gtCPT5BzTz4Pqx for ; Sun, 05 Jul 2026 03:18:37 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783221517; 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=3w0vt/eR8hBJLhvFH50lQcPxTTto3qCRK/tape+7kNY=; b=RCVOhUGlZtVDQxeAAbcz5wcP2rqdoC25poFNm+ddCs0CtunJV7GQY5gry9MQssUUrd78u7 KiqLo2uodwLB6LuNXVnOefF71aiavILZwd8uQymxMGvxRuWHDupbcYbcC2ZnDuTEV6YFBD wLFm5lG99t8+2B3MQqp8tRRFoSxAIycVTwpM/1rjP1Y+OfQHqNQuhTXthlzkh4/nuFNVBV ub16eVwFMhMOjq1DBIluaBMj8WgpqfSu5YtgjZScWx20pcBRCaAJi/jBQ0Vdzg2/VnkQKW 5oqqNTBUWIk0i/+QhA1mjJ9lgFXQ5yFsLgt53j/FT7gcKZn2fuc2q+oxGnjsIA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783221517; a=rsa-sha256; cv=none; b=N609ewJcQkCtYqROZpIYVLPBmK531I10HUahIi8pCD6qbeJin1C1DaiBVdKnBE9aUI1GTO B4btLoGtiHBLLTdOG/xNEF6BJkJ4Uc48BzPgFU8iKYZanps4x3P5t3P7ScAYnTRwD5UStl 7UfVr6nVH9ffbl17kCTxkANjlrT7jWaNfZYWYzYMDKCzS6o0fGoUmyhI+8Pnl8ivUKll75 fdyILNDzIdFu66MZ56jFQnMOGQRbCsRULpQyd99i6K20MxZelC0hVLaebbQPmbX36CULTP fEkoW9telzwYX5h/OSMdWO4tNtD1QXrOCoAbhHZX5uzj6Ae2HujYIk7VELoinw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783221517; 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=3w0vt/eR8hBJLhvFH50lQcPxTTto3qCRK/tape+7kNY=; b=dxyfBOZysJtuj7ZR1oi65D0HTj3oCOnh3zPgQFUBIpCQ9dOZbHULdim/6/BSCg+OSbYfst IYdE70rogpbPBngLS9Wf/xz054i5ge5GQs/kEA6E3NvLC1dAJYuZC0rWcRA0GWq8ouopzy kCDqxgSQGC33oZ+AkxrIWxn3kXZLENuJvzu1XMmMHFNNNBzIoSrb9aRsdnFTL47AHWCEas aaPVu9t2XQhXF4h2FZu6+rOfguJO4ERsRq4PbsisfM4yysMlZpzxaymiEMjzSfv3bldAs1 pBf7nIYITgGrok28aavZXJiwKKu3RuULY1ofR/CrVTVFCMALuw4H8sl+EvJ5zA== 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 4gtCPT429wz10xC for ; Sun, 05 Jul 2026 03:18:37 +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 6653IbSk003141 for ; Sun, 5 Jul 2026 03:18:37 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 6653IbkO003134 for threads@FreeBSD.org; Sun, 5 Jul 2026 03:18:37 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 296410] sprintf/vfprintf not thread safe on AArch64 due to localeconv_l using atomic_store_int, with relaxed semantics Date: Sun, 05 Jul 2026 03:18:37 +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: 14.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: kib@FreeBSD.org 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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: X-BeenThere: freebsd-threads@freebsd.org Sender: owner-freebsd-threads@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D296410 --- Comment #3 from Konstantin Belousov --- (In reply to Tomas Vondra from comment #2) I am not sure. For instance one thread might have noticed the change in the locale and sta= rted the rebuild, while other did not and load the partially updated data. Anyway, I think that the change to use the release semantic is fine on its = own. --=20 You are receiving this mail because: You are the assignee for the bug.= From nobody Sun Jul 5 03:19:21 2026 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 4gtCQK391Zz6jc8R for ; Sun, 05 Jul 2026 03:19:21 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gtCQK1gGZz4QLv for ; Sun, 05 Jul 2026 03:19:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783221561; 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=csRQGHQz7N/0ghhOZ+xsqsNID8dHsqOlDlq8JBDSZ6Q=; b=Dnaj7xK0C4PxArw6hKW5ZjsUbka9tvmFtIPzTHx3qMyxyh+8OtERUxi5KVUEnZcUZjFDmX TfrfTkPpvbsid8UuWY9DUBuzbAiVPusAkOFptLvwSAHq4nDsHg4MCKUuV6X/D1K8RGVtTl +wFEWkOufi6dIfKE6ZIU3zYTqoE3DahqHSPnHPWWPkOryFCagUvzWclQv4DSvL60KXrQlf C1o2TwB/DJeb5shdNtFpIlqooGCBhDxQLosDJupkFSWIbmQK+19WD8eILriLATFGHEKYNw aJ7HeXJWpjp1zlPPCyZbBUEpx12okZn95xLYOosnPue5uOmTOxeq7VVWFjSc3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783221561; a=rsa-sha256; cv=none; b=YZKz0w7w3RxGu5F7d8XCL4sqTdQjW0deoHD315TbDlKAT94SN0DWgVsv/AncHUu09YSZHC t3yw8SLVSmZlDYCHbrxnwB56e9pkBA+XsTxccrifft5m8Iakfft3kAObb3sY2K5Xz7ZAel G6VFMJMtnHL0apzeYLYV6lMKS+TKuEj9WrKZ9+Y4DzM2UG2DNmwlX5Iu4zvweT+Z30qO9p nyGrBswTPGVnnzN7oqTXLSPIN2/uc1hS04+N09FsnF0PSR8pz4nuKWjXQKaCGxD4t/PXJ+ qCAx6YWcvFWAWAOSrtrKX78ORnkV1E/EG/BL9AE3X7CQIfaS9y2o5Ka9DphlMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783221561; 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=csRQGHQz7N/0ghhOZ+xsqsNID8dHsqOlDlq8JBDSZ6Q=; b=x/zldWtdhYDK2/DPl8Jv5kkU+eJ14sUFwbKfF/HGD9K6wroyi5N0LElO4fxIuYDlnSfof6 y4vmobyAkDK4fivJOL92GiKEGcHio62DH47SX0pbakq2I06JMG56HQADiFmjS03aZkQH02 ipmUxpnw5gvpURZLXAyJTkyz2UFxI+jNUQpAoJ0k5lADrp3B3cZqGcSM9g/q+EgaP8KZVy cwEXLMx2GEhd08kdL2PMbjFmjcnqj70aMPPz3Yl/Jcd9RB9nT5DTV7OZxHiAuROVkQWSN9 mXrrZGHcC6BcVnL1JA9C4AjQ+XYL5YpBeYSSnS23k0HmALSXsKPPTxpJwSBqQg== 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 4gtCQK0fR1z10n0 for ; Sun, 05 Jul 2026 03:19: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 6653JL8K018554 for ; Sun, 5 Jul 2026 03:19:21 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from bugzilla@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 6653JLYa018553 for threads@FreeBSD.org; Sun, 5 Jul 2026 03:19:21 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: threads@FreeBSD.org Subject: [Bug 296410] sprintf/vfprintf not thread safe on AArch64 due to localeconv_l using atomic_store_int, with relaxed semantics Date: Sun, 05 Jul 2026 03:19: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: 14.4-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: commit-hook@FreeBSD.org 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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: X-BeenThere: freebsd-threads@freebsd.org Sender: owner-freebsd-threads@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D296410 --- Comment #4 from commit-hook@FreeBSD.org --- A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3D4efbcf36a0d49ab142023a767871532f5= 15f1381 commit 4efbcf36a0d49ab142023a767871532f515f1381 Author: Konstantin Belousov AuthorDate: 2026-07-05 02:50:27 +0000 Commit: Konstantin Belousov CommitDate: 2026-07-05 03:18:50 +0000 libc locale/localeconv.c: use release semantic when clearing locale_cha= nged PR: 296410 Submitted by: Tomas Vondra MFC after: 1 week lib/libc/locale/localeconv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --=20 You are receiving this mail because: You are the assignee for the bug.=