fix(android): link the SDK against the dynamic libc, not static bionic
All checks were successful
android-ci / android (pull_request) Successful in 30m59s

`openWire` segfaults at `dlopen` on every ABI, so the app dies the moment the
passphrase is submitted and the onion never publishes. The tombstone:

    signal 11 (SIGSEGV), fault addr 0x0
    #00 libonionwire_sdk.so (getauxval+21)
    #01 libonionwire_sdk.so (__cxa_atexit+604)
    #02 libonionwire_sdk.so (_GLOBAL__sub_I_superscalar.cpp+891)
    #06 libjnidispatch.so (Java_com_sun_jna_Native_open+68)
    #42 uniffi.onionwire_sdk.Onionwire_sdkKt.openWire+0

`_GLOBAL__sub_I_superscalar.cpp` is RandomX's, and RandomX arrived with the
`cuprate-daemon` feature (#113). It calls `getauxval` from a static
initializer — and `libonionwire_sdk.so` had linked bionic **statically**, so
that `getauxval` read an auxv vector only the dynamic linker ever fills in.
The first SDK call is the first `dlopen`, which is the first time anything
touches the library: the crash lands exactly on "user typed the password".

The static libc came in with the same commit that added the C++ link flags.
`linkFlags()` passes `-L<ndk>/sysroot/usr/lib/<triple>` for the libc++
archives; that directory also holds the static `libc.a`, while the dynamic
`libc.so` stub lives in the per-API subdirectory that cargo-ndk's linker
wrapper normally supplies — and that wrapper is bypassed on purpose here, so
the per-API directory was no longer on the search path at all and `-lc`
resolved to `libc.a`. Both directories are now passed, the per-API one first,
and `verifyDynamicLibc` fails the build if `libc.so` ever leaves DT_NEEDED
again.

    before (v0.9.0 arm64): NEEDED liblog.so only, local getauxval/__cxa_atexit
    after:                 NEEDED libstdc++.so, libdl, liblog, libm, libc.so, no local libc

Also: the keep-alive notice is re-announced with the locator once the node
publishes. It is anchored at the Open tap with an empty onion (so the shade
does not claim a reachable node while Tor bootstraps), and only the
POST_NOTIFICATIONS callback ever replaced it — on a device that already
granted notifications there is no callback at all, so the notice claimed
"OnionWire is starting" forever.
This commit is contained in:
apk-dev 2026-09-19 00:40:02 -04:00
commit 519f0e66c3
No known key found for this signature in database
2 changed files with 65 additions and 2 deletions

View file

@ -367,7 +367,13 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
* the system refuses anyway, [NodeHost] records why and the roster says so.
*/
private suspend fun startKeepAlive(w: Wire) {
if (NodeHost.keepAlive.value is KeepAliveStatus.On) return
// Announced even when the keep-alive is already `On`: it was anchored at
// the Open tap with an empty locator, so the notice says "OnionWire is
// starting". The POST_NOTIFICATIONS callback happens to re-announce on a
// fresh install, but on a device that already granted notifications
// there is no callback at all — the notice would then claim bootstrap
// forever. Same notification id, so this replaces it with the address
// the user can actually hand out.
KeepAliveService.start(getApplication(), w.onion())
}