From patchwork Mon Nov 30 00:52:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Murray X-Patchwork-Id: 106325 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.23235.1795999967561293366 for ; Sun, 29 Nov 2026 16:52:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@konsulko.com header.s=google header.b=Pg6rh7RS; spf=pass (domain: konsulko.com, ip: 209.85.219.49, mailfrom: scott.murray@konsulko.com) Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-91ebf4cd218so88124106d6.3 for ; Sun, 29 Nov 2026 16:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1795999966; x=1796604766; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=hVUXGlMfWdYcdwyKWVMUGIEqdZStB8tHMaZKsBE6odU=; b=Pg6rh7RSqqeZGavb9ZEhHtZocO2Um+KlX7GcgL5/w8tsPIvNhowi/Al97jaTa/uESz gwa+ZzPowZr9zILMpVkIYzVuAPmUVe4BpISWxU1A/DEZEPZq/A6zSLAEBieMgHRrLiYT XhnwAqIr6bi3bxc5nCmX/pA0RtSYUMZbKSygU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795999966; x=1796604766; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=hVUXGlMfWdYcdwyKWVMUGIEqdZStB8tHMaZKsBE6odU=; b=yqtYYsZnCrfbCwfHReutqDz9Yg8cGXvJaULZuiLFpoyTkjT4CwWH2I6VhpbHVTDoDp kofBGdKJSGZ2vXoab968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c5XQ2vJEh11F+rNuSLyZZSp5Cr01 LONFRsa51+0CRtKnuZOgBdAlz049h6yMbhMJAOMbeXXP4Qp3w2TUBXqF80Ub4TvAFKA== X-Received: by 2002:a05:6214:528a:b0:91c:7a0e:3385 with SMTP id 6a1803df08f44-92134b28611mr614145396d6.49.1795999966225; Sun, 29 Nov 2026 16:52:46 -0800 (PST) Return-Path: Received: from ghidorah.spiteful.org (107-179-213-3.cpe.teksavvy.com. [107.179.213.3]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921787fd72asm141946796d6.12.2026.11.29.16.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 16:52:45 -0800 (PST) From: Scott Murray To: yocto-patches@lists.yoctoproject.org Subject: [meta-lts-mixins][wrynose/rust][PATCH 06/10] rust: Fix intermittent test failure Date: Sun, 29 Nov 2026 19:52:24 -0500 Message-ID: X-Mailer: git-send-email 2.56.1 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 00:52:51 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5593 From: Deepesh Varatharajan Fixes [YOCTO #16460] Fix an intermittent test failure by backporting the upstream Rust commit. https://github.com/rust-lang/rust/commit/a292cb16d5cfc32923be91c86afaf727682a38dc Signed-off-by: Deepesh Varatharajan Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie (adapted from oe-core commit 5dbd586fa8a9ad1a5e0193986f1ed67e14b8c3ae) Signed-off-by: Scott Murray --- ...se-thread-local-in-c_str_alloc_error.patch | 64 +++++++++++++++++++ recipes-devtools/rust/rust-source.inc | 1 + 2 files changed, 65 insertions(+) create mode 100644 recipes-devtools/rust/files/0006-alloctests-use-thread-local-in-c_str_alloc_error.patch diff --git a/recipes-devtools/rust/files/0006-alloctests-use-thread-local-in-c_str_alloc_error.patch b/recipes-devtools/rust/files/0006-alloctests-use-thread-local-in-c_str_alloc_error.patch new file mode 100644 index 0000000..f213220 --- /dev/null +++ b/recipes-devtools/rust/files/0006-alloctests-use-thread-local-in-c_str_alloc_error.patch @@ -0,0 +1,64 @@ +From a292cb16d5cfc32923be91c86afaf727682a38dc Mon Sep 17 00:00:00 2001 +From: Jules Bertholet +Date: Mon, 16 Nov 2026 09:24:03 -0500 +Subject: [PATCH] alloctests: use thread-local in `c_str_alloc_error` + +Upstream-Status: Backport [https://github.com/rust-lang/rust/commit/a292cb16d5cfc32923be91c86afaf727682a38dc] +Signed-off-by: Deepesh Varatharajan + +diff --git a/library/alloctests/tests/c_str_alloc_error.rs b/library/alloctests/tests/c_str_alloc_error.rs +index 1e7d54d75b3..fc572169583 100644 +--- a/library/alloctests/tests/c_str_alloc_error.rs ++++ b/library/alloctests/tests/c_str_alloc_error.rs +@@ -15,20 +15,22 @@ + #![feature(alloc_error_hook)] + + use std::alloc::{GlobalAlloc, Layout, System, set_alloc_error_hook}; ++use std::cell::Cell; + use std::ffi::CString; + use std::panic::{AssertUnwindSafe, catch_unwind}; +-use std::sync::atomic::{AtomicBool, Ordering}; + + // Once armed, the first allocation of 8 bytes or more fails and disarms, so the + // reallocation inside `clone_into`'s grow path fails while the runtime's own + // smaller allocations keep succeeding. + struct OneShotFailingAlloc; + +-static ARMED: AtomicBool = AtomicBool::new(false); ++thread_local! { ++ static ARMED: Cell = const { Cell::new(false) }; ++} + + unsafe impl GlobalAlloc for OneShotFailingAlloc { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { +- if layout.size() >= 8 && ARMED.swap(false, Ordering::SeqCst) { ++ if layout.size() >= 8 && ARMED.replace(false) { + return core::ptr::null_mut(); + } + unsafe { System.alloc(layout) } +@@ -39,7 +41,7 @@ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + } + + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { +- if new_size >= 8 && ARMED.swap(false, Ordering::SeqCst) { ++ if new_size >= 8 && ARMED.replace(false) { + return core::ptr::null_mut(); + } + unsafe { System.realloc(ptr, layout, new_size) } +@@ -59,11 +61,11 @@ fn clone_into_alloc_failure_leaves_target_valid() { + let src = CString::new("a fairly long value").unwrap(); + let mut target = CString::new("x").unwrap(); + +- ARMED.store(true, Ordering::SeqCst); ++ ARMED.set(true); + // Under Miri the failing allocator is honored, so this reallocation unwinds; in a + // normal build the allocator can't intercept it and `clone_into` just succeeds. + let res = catch_unwind(AssertUnwindSafe(|| src.as_c_str().clone_into(&mut target))); +- ARMED.store(false, Ordering::SeqCst); ++ ARMED.set(false); + + if cfg!(miri) { + assert!(res.is_err(), "clone_into should have unwound on the alloc failure"); +-- +2.49.0 + diff --git a/recipes-devtools/rust/rust-source.inc b/recipes-devtools/rust/rust-source.inc index ed779f3..94a20a5 100644 --- a/recipes-devtools/rust/rust-source.inc +++ b/recipes-devtools/rust/rust-source.inc @@ -8,6 +8,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n file://0003-cargo-omit-host-triple-from-unit-metadata-hash.patch;patchdir=${RUSTSRC} \ file://0004-Re-bless-tests-adjust-for-new-Cargo-lints.patch;patchdir=${RUSTSRC} \ file://0005-rustc_llvm-drop-native-sysroot-L-when-cross-building.patch;patchdir=${RUSTSRC} \ + file://0006-alloctests-use-thread-local-in-c_str_alloc_error.patch;patchdir=${RUSTSRC} \ " SRC_URI[rust.sha256sum] = "90dab90b8084eb57c35ae2b1d0b70c8e5138ace6023b22c60a5a400f586f63b2"