Validate source snippet when format input is raw string#152277
Validate source snippet when format input is raw string#152277gurry wants to merge 1 commit intorust-lang:mainfrom
Conversation
70647fa to
4483628
Compare
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
Thank you. I found another related ICE while reviewing the PR, so if possible, could you take a look at fixing that as well?
The implementation might have a somewhat broader impact, so I’d like to review it more carefully on my side. Please give me a little more time.
| let suffix_len = nr_hashes + 1; // closing " + hashes | ||
| if snippet.len() >= prefix_len + suffix_len // is sufficiently long | ||
| && snippet.starts_with('r') | ||
| && snippet[1..1 + nr_hashes].chars().all(|c| c == '#') |
There was a problem hiding this comment.
I found foo!(r字字); causes an ICE with your implementation in this line. Could you check it? It pre-existed, but the ICE error message changed in the PR.
There was a problem hiding this comment.
@TaKO8Ki I have pushed a fix for this. No longer trying to convert bytes to chars while doing comparisons.
No worries. Please take your time. I'll fix the second ICE in the meanwhile. |
a1cee4e to
42a2960
Compare
42a2960 to
6b3d04e
Compare
|
@bors try jobs=x86_64-gnu |
This comment has been minimized.
This comment has been minimized.
Validate source snippet when format input is raw string try-job: x86_64-gnu
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Validate source snippet when format input is raw string
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (0421599): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -2.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 492.161s -> 479.296s (-2.61%) |
Fixes #114865
The issue occurred because the user's proc macro respanned the format arg to an unrelated multi-byte string and we ICE'd by landing in the middle of a multi-byte char.
This PR adds validation that prevents the parser from trying to walk such obviously wrong snippets. Such validation already existed for non-raw strings. This PR adds it for raw strings as well.