Fix build crash when compiler output is not valid UTF-8#8482
Open
nathan-tranquilla wants to merge 3 commits into
Open
Fix build crash when compiler output is not valid UTF-8#8482nathan-tranquilla wants to merge 3 commits into
nathan-tranquilla wants to merge 3 commits into
Conversation
bsc can print a code frame that cuts a multi-byte character in half, so the captured stderr is not always valid utf-8. The Ok branch decodes it with from_utf8().expect(), which panics and takes down the whole build with a byte offset into stdout and no file name. This test feeds a truncated em dash and reproduces the panic.
The Ok branch used from_utf8().expect() on the captured stderr, which panics when the output is not valid utf-8. The two sibling branches right above it already use from_utf8_lossy. Use it here too so a truncated character turns into a replacement character and the build keeps going instead of crashing.
Member
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
fhammerschmidt
approved these changes
Jun 22, 2026
fhammerschmidt
left a comment
Member
There was a problem hiding this comment.
Thanks for reporting and fixing.
fhammerschmidt
requested changes
Jun 22, 2026
fhammerschmidt
left a comment
Member
There was a problem hiding this comment.
Ah yes, would you add a Changelog entry, please?
rescript
@rescript/darwin-arm64
@rescript/darwin-x64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
Author
|
Addressed, thanks! |
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.
We ran into this panic in CI on a production app we're building with ReScript. The
Okbranch incompile.rsdecodes bsc's captured stderr withfrom_utf8().expect(), which crashes the whole build when that output is not valid UTF-8, while the two branches right above it already usefrom_utf8_lossy. bsc does produce invalid UTF-8 when a styled code frame cuts a multi-byte character mid-byte: compiling a line with an em dash, we captured a lonee2(the first byte of U+2014) followed immediately by an ANSI escape. This switches that branch tofrom_utf8_lossytoo; the first commit adds a unit test that reproduces the panic and the second applies the fix.