Repository navigation
Conversation
Android's log and the browser's console take C strings, and `__private_api_log_lit` built them with `CString::new(message).unwrap_or_else(|_| panic!())`. So a message holding a NUL byte panicked inside `warn!` or `error!`, with no message of its own, and never reached the log. That happens whenever a message quotes data the app doesn't control, such as the text of a file it failed to parse. Each NUL is now replaced with U+FFFD, the replacement character, so the rest of the message still reaches the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
On Android and wasm,
__private_api_log_litturns the message into a C string withCString::new(message).unwrap_or_else(|_| panic!()). So a message holding a NUL byte panics insidewarn!orerror!, with no message of its own, and never reaches the log. That happens whenever a message quotes data the app doesn't control, such as a parse error quoting a corrupt file:Change
A
c_stringhelper replaces each NUL with U+FFFD, the replacement character, before building the C string, so the rest of the message still reaches the log. The Android and wasm paths both use it, and a test covers the replacement.Verification
warn!. With this change, Logcat shows the warning with�where the NULs were, and the game carries on.cargo test --features log-implpasses on macOS, new test included.cargo check --features log-implpasses foraarch64-linux-androidandwasm32-unknown-unknown. I didn't run the wasm path in a browser.🤖 Generated with Claude Code