Repository navigation
Fix Apple's library crashing the app on some phones, and keep the keyboard off the server field (1.1.1) - #233
Merged
Conversation
Issue #232. On a Pixel 5 and a Redmi Note 12 Pro, 1.1.0 exits the moment it opens. The crash log names it exactly: SIGBUS (BUS_ADRALN) inside Apple's libstoreservicescore.so, in its own static initialisers, under linker64 call_constructors <- dlopen <- NativeAdi.open - before this app has called a single ADI function. It is the pinned arm64 binary, size and SHA-256 checked, byte for byte the one that works on other phones. LocalAnisette.ensureReady catches every exception and falls back to a remote Anisette server, which is the right design and could not help: a signal is not an exception. The process died inside the call, the catch never ran, and because the sign-in screen checks Anisette as soon as it opens, it happened again on every launch. There was no way to reach Settings and pick a server, and 1.0.5 can no longer sign in at all, so affected users had nothing. NativeLoadGuard writes a record immediately before the native calls and removes it after they return or throw. A record still present at the next launch means the load never returned, so that launch uses a server instead. The user meets the crash once rather than on every launch. Details that decide whether it works: - The check runs inside the once-per-process load lock. Two threads loading at once is ordinary (#135); checked outside it, the second would read the first one's in-progress record as a crash. - The window is exactly AdiLibrary.open and initialise - native, and milliseconds. Provisioning is outside it, since it waits on the network and a user closing the app then would switch local Anisette off for nothing. - The store commits synchronously. apply() queues the write, and the queue dies with the process, so it would pass every test and never record a crash. - The record names the app version, ABI and library build, and only a record for the same attempt counts. An update retries, so a fix reaches the devices it was for instead of them being written off permanently. - An exception clears the record before rethrowing. The process survived and the existing fallback handles it. Nine JVM tests, compiled and run locally with javac and JUnit rather than left to CI. Two mutations checked by hand: writing the record after the load fails the test that asserts it exists while Apple's code runs, and making the check consume the record fails the one asserting it stays off on later launches. LocalAnisette itself needs the Android SDK and is not compiled here. AGENTS.md rule 4 records why a native crash bypasses the fallback, and why CI as it stands cannot see this class - x86_64 downloads Apple's x86_64 build, and the tests that load the real library are opt-in. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Hotfix for #232: Apple's ADI library crashing the app on launch on some devices. versionCode moves with versionName so installs can upgrade. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
wanderdev0
temporarily deployed
to
Android Build
September 17, 2026 14:45 — with
GitHub Actions
Inactive
wanderdev0
temporarily deployed
to
Android Build
September 17, 2026 14:45 — with
GitHub Actions
Inactive
Targeting SDK 35 makes windows edge to edge on Android 15, and an edge-to-edge window is not resized when the keyboard opens, so adjustResize did nothing and the Anisette server field was drawn underneath the keyboard while somebody typed into it. The sign-in screen now takes the keyboard's inset as a bottom margin on its ScrollView. A margin rather than padding, because a ScrollView only scrolls the focused field into view when it gets shorter. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The guard only learns from a crash that already happened, so an affected phone still crashed once - including everyone updating from 1.1.0, who has no record of the crash yet. AppleLibraryProbeService, in its own :adiprobe process, now loads and initialises Apple's library before the app does. If that process dies, the binder reports it, the app records it and uses a remote Anisette server, and nobody sees a crash. If it survives, the app loads the library itself, still under NativeLoadGuard. The answer is kept per app version, ABI and library build, so the extra process runs once. A phone the library crashes on is told so on the sign-in screen and offered a "Report this phone" button, which opens the existing report screen with the model, Android version, ABI and library build filled in. OpenAirTagApplication no longer extends PyApplication and returns early in the probe process, so Python is not started from two processes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
wanderdev0
temporarily deployed
to
Android Build
September 17, 2026 15:06 — with
GitHub Actions
Inactive
wanderdev0
had a problem deploying
to
Android Build
September 17, 2026 15:06 — with
GitHub Actions
Failure
mediaplatform::WorkQueue::makeWorkQueue returns a std::shared_ptr by value, which comes back through a buffer the caller provides (x8 on arm64, a hidden first argument on x86_64). Our generated stub returned 0 in a register and never wrote it. The static constructor for URLBagRequest::_queue in libstoreservicescore.so then read the leftover stack as a control block and incremented its reference count through it. Zero on most phones, so the increment was skipped; a live misaligned pointer on a Pixel 5 and a Redmi Note 11 Pro+ 5G, where dlopen died with SIGBUS BUS_ADRALN in __aarch64_ldadd8. The stub is now written by hand in C++, returning a two-pointer struct with a non-trivial destructor, which forces the same indirect return on both ABIs. The generator skips any symbol the hand-written file defines. MakeWorkQueueStubTest calls it the way Apple's code does, with the real std::shared_ptr return type, into a garbage-filled buffer, so it fails on any ABI without Apple's library. Checked on this Mac for arm64 and x86_64: the old stub leaves the garbage, the new one returns empty, and the same struct without its destructor leaves the garbage too. Found by disassembling the pinned arm64 libstoreservicescore.so against the crash log from #232. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
wanderdev0
temporarily deployed
to
Android Build
September 17, 2026 15:12 — with
GitHub Actions
Inactive
wanderdev0
had a problem deploying
to
Android Build
September 17, 2026 15:12 — with
GitHub Actions
Failure
kill() delivers SIGBUS to whichever thread the process picks - on the emulator, the main one - and the system writes a crash report before the process is gone. The hook returned from kill(), so the loading thread went on, failed its empty load and replied "survived" 11ms after the fatal signal, before the death (seen in the logcat of the failing CI run). A real crash is in the loading thread and can send nothing, so the hook now never returns: it sleeps, and kills the process outright if it is somehow still alive after ten seconds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
wanderdev0
temporarily deployed
to
Android Build
September 17, 2026 16:11 — with
GitHub Actions
Inactive
wanderdev0
temporarily deployed
to
Android Build
September 17, 2026 16:11 — with
GitHub Actions
Inactive
1 task done
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #232.
What the crash log shows
From @PBue's
adb logcat -b crashon a Redmi Note 11 Pro+ 5G (pissarropro), Android 13:Apple's library dies inside
dlopen, in its own static initialisers, before this app calls a single ADI function.The cause: our
makeWorkQueuestubmediaplatform::WorkQueue::makeWorkQueuereturns astd::shared_ptrby value. That comes back through a buffer the caller provides:x8on arm64, a hidden first argument on x86_64. Our generated stub islong f(void) { return 0; }, which never writes that buffer. The static constructor forURLBagRequest::_queue(init_array[47]) then reads the leftover stack as{object, control}and increments the reference count atcontrol+8:On most phones the leftover is zero and nothing happens. On these two it is a live pointer that is not 8-aligned, and the exclusive load takes an alignment fault (
SIGBUS/BUS_ADRALN). Every register in the tombstone matches this path. x86_64 has the same bug and was only lucky.The fix hand-writes the stub in
stubs/libmediaplatform_handwritten.cpp. It returns a two-pointer struct with a non-trivial destructor, which forces the same indirect return on both ABIs, and the generator skips any symbol that file defines.libmediaplatform.expected,docs/anisette-native-android.mdand AGENTS.md rule 4 all called this call harmless because provisioning succeeded. They are corrected.The guard and the separate-process load below stay as defence against the next native crash nobody has found yet.
Why the existing fallback could not help
ensureReadycatches every exception and falls back to a remote Anisette server. A signal is not an exception. The process died inside the call, thecatchnever ran, and because the sign-in screen checks Anisette as soon as it opens, it happened on every launch. Affected users could not reach Settings to choose a server, and 1.0.5 can no longer sign in at all — so they had nothing.Surviving a native crash anyway
NativeLoadGuardwrites a record immediately before the native calls and removes it after they return or throw. A record still present at the next launch means the load never returned, so that launch uses a server. Affected users meet the crash once, then the app works — landing on the server-choice step that existed before local Anisette.The details that decide whether it works:
AdiLibrary.open+initialise— native, milliseconds. Provisioning stays outside: it waits on the network, and a user closing the app then would switch local Anisette off for nothing.commit(), notapply().apply()queues the write and the queue dies with the process — it would pass every test and never record a crash.Loading it somewhere else first
On its own the guard only learns from a crash that already happened, so an affected phone would still crash once, including everyone updating from 1.1.0.
AppleLibraryProbeServiceruns in its own process (android:process=":adiprobe") and loads and initialises the library before the app does. If that process dies, the binder reports it, the answer is recorded, and the app uses a remote server. Nobody sees a crash. If it survives, the app loads the library itself, still underNativeLoadGuard. The answer is kept per app version, ABI and library build, so this runs once per update.LocalAnisette.openAndInitialise, so the test load and the real load make the same calls into Apple's code.OpenAirTagApplicationextendsApplicationinstead ofPyApplication(which only calledPython.start) and returns early in the probe process, so Python is not started twice.A phone the library crashes on sees a sentence saying so above the server field, plus a Report this phone button. It opens the existing report screen with model, Android version, ABI and library build filled in.
Keyboard covering the Anisette server field
Targeting SDK 35 makes windows edge to edge on Android 15, and
adjustResizeno longer resizes them. The sign-in screen now takes the IME inset as a bottom margin on itsScrollView, which shrinks it and scrolls the focused field into view.Tests
JVM, compiled and run locally with
javacand JUnit 4.13.2:SurvivingAppleLibraryCrashingOnLoadTest: 9/9. Mutations checked by hand: writing the record after the load, and a check that consumes the record.TryingApplesLibraryElsewhereFirstTest: 7/7. Mutations checked by hand: not recording a death, loading on no answer, recording when the service could not start. Each is caught by exactly one test.Native, run locally on this Mac for arm64 and x86_64 (Rosetta), against a caller declared with the real
std::shared_ptrreturn type and a buffer pre-filled with0xA5:0xa5a5…on both ABIs.shared_ptron both.0xa5a5…on both, which shows the destructor is what does the work.Instrumented, CI's word only:
MakeWorkQueueStubTest: the same garbage-buffer call, made fromadi.cppthroughdlsymon the device. It needs no Apple library, so it runs in the default suite on x86_64.ApplesLibraryInASeparateProcessTest: the probe process kills itself with a realSIGBUS, the app seesDIEDand keeps running, and a second probe afterwards answers normally. It also checks that a load which throws counts as survived, not as a crash. There is only one crash in the whole suite, to avoid the "keeps stopping" dialog.AnisetteStatusTest,LoginAnisetteFallbackLayoutTest: the new state, the sentence and button, and a report that names the phone.WindowPaddingUtilTest: margin in, margin out, and a focusedEditTextending up above a 600px keyboard.Not verified: no test loads Apple's real library on arm64, and nobody affected has run a build with the stub fix yet. CI's emulator is x86_64 and the real-library tests are opt-in (AGENTS.md rule 4). The keyboard fix has not been seen on a real Android 15 phone.
58c04fabumps the app to 1.1.1 (versionCode5).🤖 Generated with Claude Code