Fix android crash when a realm is unreachable - #14
Merged
Imperiopolis merged 1 commit intoAug 1, 2026
Conversation
if one host fails (connectexception), the android http callback builds a fake error response and hands it back to native. without that completing cleanly, the app dies and never finishes. on the fake response (id, body, headers) so jni would not panic on null id. still set statuscode = -1. jni reads status as a java short (signed) and converts it to rust u16 with try_into().unwrap(). -1 is valid as a short but not as a non-negative u16, so unwrap still panics in native after the catch. set statuscode = 0 instead of -1. 0 converts cleanly; rust treats an invalid/non-success status as a network error for that realm so other realms can still succeed. • [x] block one realm host via custom DNS, enter pin → no crash; • [x] block all realms → enter pin -> no crash;
edenman
approved these changes
Jul 17, 2026
Contributor
Author
|
@Imperiopolis could you review this? :) |
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.
context
if one host fails (connectexception), the android http callback builds a fake error response and
hands it back to native. without that completing cleanly, the app dies and never finishes.
previous fix
#13 (#13) (eric) filled in missing fields
on the fake response (id, body, headers) so jni would not panic on null id.
but
statuscode = -1was still there.why that was not enough
jni reads status as a java short (signed) and converts it to rust u16 with try_into().unwrap().
-1 is valid as a short but not as a non-negative u16, so unwrap still panics in native after the catch.
this change
set statuscode = 0 instead of -1.
0 converts cleanly;
rust treats an invalid/non-success status as a network error for that realm so other realms can still succeed.
test
• [x] block one realm host via custom DNS, enter pin → no crash;
• [x] block all realms → enter pin -> no crash;