From 0224ce654cd5f6a486f864ae63942a48af035cd2 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Thu, 9 Apr 2026 15:47:30 +0400 Subject: [PATCH] =?UTF-8?q?step=20E.2:=20shrink=20cpp=5Fsmoke=20to=20std::?= =?UTF-8?q?atomic=20only=20=E2=80=94=20no=20thread,=20no=20mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Incremental bisection within Step E. E.4 (atomic + mutex + thread) still crashed at __init_tcb. Drop mutex and thread, keep only std::atomic. Build.rs still emits cargo:rustc-link-lib=c++_shared via cpp_link_stdlib('c++_shared'), so the NEEDED entry for libc++_shared.so in the final .so stays identical. Goal: if this crashes, the issue is purely the dynamic link against libc++_shared (not thread/mutex code). If it passes, the issue is actually std::thread or std::mutex use. Co-Authored-By: Claude Opus 4.6 (1M context) --- desktop/src-tauri/cpp/cpp_smoke.cpp | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/desktop/src-tauri/cpp/cpp_smoke.cpp b/desktop/src-tauri/cpp/cpp_smoke.cpp index ab6c0be..42b7287 100644 --- a/desktop/src-tauri/cpp/cpp_smoke.cpp +++ b/desktop/src-tauri/cpp/cpp_smoke.cpp @@ -1,30 +1,19 @@ -// cpp_smoke.cpp — minimal C++ test that exercises the libc++_shared -// features Oboe uses (std::thread, std::mutex, std::atomic) without being -// Oboe itself. +// cpp_smoke.cpp — Step E.2 minimal stub: std::atomic only, no thread/mutex. // -// Built via cc::Build::new().cpp(true).cpp_link_stdlib("c++_shared") and -// replaces the full Oboe bridge compile during the Step E bisection of -// the __init_tcb+4 crash. The function is `extern "C"` and exported so -// the linker can't dead-code-eliminate it — the std::thread / -// std::lock_guard / std::atomic::fetch_add uses pull in libc++'s -// bindings to bionic pthread, matching what Oboe would force. +// Linked via cpp_link_stdlib("c++_shared") so the resulting .so still carries +// a NEEDED entry for libc++_shared.so exactly like the Oboe build would. // -// The function is NEVER called from Rust. If we crash anyway, the trigger -// is just *linking* this code in. If it launches cleanly, Oboe itself -// (size, static ctors, specific headers) is the culprit. +// Same extern "C" export as E.4 so the linker CAN pull the symbol in if it +// chooses to, but since Rust never calls it, it'll typically be dead-stripped. +// The diagnostic value is in the build.rs link directives this compile +// produces, not in the file's actual code being linked. #include -#include -#include namespace { std::atomic g_counter{0}; - std::mutex g_mutex; } extern "C" int wzp_cpp_smoke(void) { - std::lock_guard lock(g_mutex); - std::thread t([]() { g_counter.fetch_add(1); }); - t.join(); - return g_counter.load(); + return g_counter.fetch_add(1); }