From 0d743665926e9f7d70a08754dd95f87cd522df61 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Thu, 9 Apr 2026 15:54:21 +0400 Subject: [PATCH] step E.1: absolute minimum C++ file (no STL, no includes) Last bisection step. cpp/cpp_smoke.cpp reduced to a single extern 'C' function that returns 42. No #include, no std::atomic, no std::mutex, no std::thread. Only C++ things remaining are: - cc::Build::new().cpp(true) in build.rs (C++ mode compile) - cpp_link_stdlib('c++_shared') emitting -lc++_shared If this still crashes with the same __init_tcb+4 / pthread_create stack, we've conclusively proven the trigger is NOT any C++ code that ends up in the final .so (everything gets dead-stripped anyway because Rust never references wzp_cpp_hello). The trigger must be either: a) cargo:rustc-link-lib=c++_shared (adds NEEDED entry for libc++_shared.so in the .so's dynamic table, causing the dynamic linker to load libc++_shared.so at dlopen() time alongside our .so), or b) Some interaction between cpp(true) mode and the rest of the build pipeline (toolchain flags, symbol visibility, etc.) After this build we stop and write an incident report for the WarzonePhone Tauri Android rewrite bisection so far. Co-Authored-By: Claude Opus 4.6 (1M context) --- desktop/src-tauri/cpp/cpp_smoke.cpp | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/desktop/src-tauri/cpp/cpp_smoke.cpp b/desktop/src-tauri/cpp/cpp_smoke.cpp index 42b7287..9d7b469 100644 --- a/desktop/src-tauri/cpp/cpp_smoke.cpp +++ b/desktop/src-tauri/cpp/cpp_smoke.cpp @@ -1,19 +1,14 @@ -// cpp_smoke.cpp — Step E.2 minimal stub: std::atomic only, no thread/mutex. +// cpp_smoke.cpp — Step E.1: the absolute minimum C++ file. +// No #include, no STL, no atomics, no thread, no mutex. Just one function. +// Still compiled as .cpp(true) with cpp_link_stdlib("c++_shared"), so the +// only delta vs the non-crashing baseline is: +// 1. cc::Build using cpp(true) (vs plain C in hello.c) +// 2. cargo:rustc-link-lib=c++_shared emitted by cc-rs (adds NEEDED +// entry for libc++_shared.so in the final .so) // -// 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. -// -// 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. +// If this crashes, we've conclusively proven the trigger is one of those +// two things — not any C++ code behavior. -#include - -namespace { - std::atomic g_counter{0}; -} - -extern "C" int wzp_cpp_smoke(void) { - return g_counter.fetch_add(1); +extern "C" int wzp_cpp_hello(void) { + return 42; }