-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Rustc memory exhaustion when formatting short code suggestion #76597
Comments
@rustbot prioritize |
It sounds like there are two issues here:
Does that sound accurate? |
It seems like 1) should be fixed automatically if you fix 2), no? Since there's nothing wrong with the diagnostic itself, it just hit an edge case in the library. |
I agree with that. Once the edge case will be correctly handled, the diagnostic itself should be OK. And this is validated according to the test case which prints the diagnostic in stderr with the patch, but consumes memory in master. |
Well, when adding rustfix (and corresponding .fixed file) for this new test case, it passes only when reverting identified regression line from #73953. But then another test case breaks (similar_tokens.rs). I guess that:
I'll continue to explore this path. |
I finally managed to pass all tests with rustfix, after the addition of a test for multiline span when calling |
I'm confused by what problem you're trying to solve. I guess open a new PR, but I don't know what it's fixing. |
I'm sorry if I wasn't clear. The PR #76598 fixes the memory bug in But I have a new patch to submit to solve these problems. It's about |
I'd say add it on to your existing PR, since it sounds like it depends on those changes. |
Indeed, I just pushed it. Thank you for your answers. |
…stebank Fixing memory exhaustion when formatting short code suggestion Details can be found in issue rust-lang#76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.
…stebank Fixing memory exhaustion when formatting short code suggestion Details can be found in issue rust-lang#76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.
…stebank Fixing memory exhaustion when formatting short code suggestion Details can be found in issue rust-lang#76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.
…ebank Fixing memory exhaustion when formatting short code suggestion Details can be found in issue rust-lang#76597. This PR replaces substractions with `saturating_sub`'s to avoid usize wrapping leading to memory exhaustion when formatting short suggestion messages.
Fixed by #76598 |
Code
Meta
rustc --version --verbose
:Stable channel seems to be also affected from version 1.46.
The bug is reproducible in rust playground.
Error output
When trying to compile this code with
rustc
, nothing is displayed, and memory exhaustion happens, leading to either SIGABRT if user virtual memory is (u)limited, or memory swapping and eventually freezing the machine.One would have expected syntax error as follows:
Analysis
Backtrace
Here is a gdb backtrace after SIGABRT:
Finding regression
After
ulimit -v 8000000
, we usedcargo-bisect-rustc
with the following script:Here is the execution result:
The bug was introduced when auditting hidden/short code suggestions #73953 with the change of the span used when reporting a
missing ','
suggestion (https://github.com/rust-lang/rust/pull/73953/files#diff-da8eccd50b4abe306482925ebf6e6a90R702).After further investigation, we found that the problem resides in the construction of the error message, in the module
rustc_errors
. When applying left margin shift in the functionFileWithAnnotatedLines::render_source_line
, the column number can wrap over usize (emitter.rs#962), thus the function draw_range tries toputc
way too many '_' chars into theStyledBuffer
.A fix would be to
saturating_sub
when computing column number (in emitter.rs, at line 962, and also at lines 969 and 970), in the same way it is already done at different points of the same function.For completion, further inspection of the multispan data would be required to check whether they are correct.
Aurélien Deharbe and Vincent Dagonneau
The text was updated successfully, but these errors were encountered: