step E.2: shrink cpp_smoke to std::atomic only — no thread, no mutex
Some checks failed
Mirror to GitHub / mirror (push) Failing after 38s
Build Release Binaries / build-amd64 (push) Failing after 3m48s

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) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-04-09 15:47:30 +04:00
parent aa240c6d83
commit 0224ce654c

View File

@@ -1,30 +1,19 @@
// cpp_smoke.cpp — minimal C++ test that exercises the libc++_shared // cpp_smoke.cpp — Step E.2 minimal stub: std::atomic only, no thread/mutex.
// features Oboe uses (std::thread, std::mutex, std::atomic) without being
// Oboe itself.
// //
// Built via cc::Build::new().cpp(true).cpp_link_stdlib("c++_shared") and // Linked via cpp_link_stdlib("c++_shared") so the resulting .so still carries
// replaces the full Oboe bridge compile during the Step E bisection of // a NEEDED entry for libc++_shared.so exactly like the Oboe build would.
// 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.
// //
// The function is NEVER called from Rust. If we crash anyway, the trigger // Same extern "C" export as E.4 so the linker CAN pull the symbol in if it
// is just *linking* this code in. If it launches cleanly, Oboe itself // chooses to, but since Rust never calls it, it'll typically be dead-stripped.
// (size, static ctors, specific headers) is the culprit. // The diagnostic value is in the build.rs link directives this compile
// produces, not in the file's actual code being linked.
#include <atomic> #include <atomic>
#include <mutex>
#include <thread>
namespace { namespace {
std::atomic<int> g_counter{0}; std::atomic<int> g_counter{0};
std::mutex g_mutex;
} }
extern "C" int wzp_cpp_smoke(void) { extern "C" int wzp_cpp_smoke(void) {
std::lock_guard<std::mutex> lock(g_mutex); return g_counter.fetch_add(1);
std::thread t([]() { g_counter.fetch_add(1); });
t.join();
return g_counter.load();
} }