step E.2: shrink cpp_smoke to std::atomic only — no thread, no mutex
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:
@@ -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 <atomic>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace {
|
||||
std::atomic<int> g_counter{0};
|
||||
std::mutex g_mutex;
|
||||
}
|
||||
|
||||
extern "C" int wzp_cpp_smoke(void) {
|
||||
std::lock_guard<std::mutex> lock(g_mutex);
|
||||
std::thread t([]() { g_counter.fetch_add(1); });
|
||||
t.join();
|
||||
return g_counter.load();
|
||||
return g_counter.fetch_add(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user