-
Notifications
You must be signed in to change notification settings - Fork 14k
Fix ICE when include_str! reads binary files #149321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Okay, the invalid bytes are all different.. |
|
@rustbot reroll |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| //@ normalize-stderr: "`[^`\n]*invalid-utf8-binary-file\.bin`" -> "`$DIR/invalid-utf8-binary-file.bin`" | ||
| //@ rustc-env:INVALID_UTF8_BIN={{src-base}}/include-macros/invalid-utf8-binary-file.bin | ||
|
|
||
| //! Ensure that ICE does not occur when reading an invalid UTF8 file with an absolute path. | ||
| //! regression test for issue <https://github.com/rust-lang/rust/issues/149304> | ||
|
|
||
| #![doc = include_str!(concat!(env!("INVALID_UTF8_BIN")))] //~ ERROR: wasn't a utf-8 file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ICE seemed to occur when reading an invalid binary file with an absolute path. So I used env like this to give an absolute path, but is there a better way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it depend on the path?
I'd expect it to only depend on the file's contents.
What exactly cases of invalid UTF-8 trigger the bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I ran this code (use relative path)
#![doc = include_str!("invalid-utf8-binary-file.bin")] //~ ERROR: wasn't a utf-8 file
fn main() {}diffrent error occur.
error: `invalid-utf8-binary-file.bin` wasn't a utf-8 file
--> invalid-utf8-binary-file.bin:1:3
|
LL | MZ�␀
| ^ byte `144` is not valid utf-8
error: aborting due to 1 previous error
ans ICE does not occur even if I do not modify compiler/rustc_parse/src/lib.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why source.normalized_source_len.0 can be less than start, because contents.len() should always be larger (or equal?) to start.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
ICE occurred when an invalid UTF8 file with an absolute path were included.
resolve: #149304