Skip to content

Conversation

@reddevilmidzy
Copy link
Contributor

@reddevilmidzy reddevilmidzy commented Nov 25, 2025

ICE occurred when an invalid UTF8 file with an absolute path were included.

resolve: #149304

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 25, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@reddevilmidzy
Copy link
Contributor Author

Okay, the invalid bytes are all different..

@reddevilmidzy reddevilmidzy marked this pull request as ready for review November 26, 2025 09:41
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 26, 2025
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@lcnr
Copy link
Contributor

lcnr commented Nov 26, 2025

@rustbot reroll

@rustbot rustbot assigned petrochenkov and unassigned lcnr Nov 26, 2025
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Nov 27, 2025
Copy link
Contributor Author

@reddevilmidzy reddevilmidzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rustbot ready

(tidy awesome...)

View changes since this review

Comment on lines +2 to +8
//@ 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
Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 27, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 27, 2025
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

..............................F
======== tests/rustdoc-gui/globals.goml ========

[ERROR] `tests/rustdoc-gui/globals.goml` line 14: The following errors happened: [Property named `"searchIndex"` doesn't exist]: for command `assert-window-property-false: {"searchIndex": null}`


<= doc-ui tests done: 30 succeeded, 114 failed, 0 filtered out

Error: ()

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tidy Area: The tidy tool S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: Annotation range 24..24 is beyond the end of buffer 0

5 participants