-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Fix normalization overflow ICEs in monomorphization #146096
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: master
Are you sure you want to change the base?
Fix normalization overflow ICEs in monomorphization #146096
Conversation
r? codegen |
@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.
…ono1, r=<try> Fix normalization overflow ICEs in monomorphization
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (fb35892): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @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 9.4%, secondary 6.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 11.3%, secondary 16.9%)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: 467.236s -> 465.852s (-0.30%) |
Fixes #92004
Fixes #92470
Fixes #95134
Fixes #105275
Fixes #105937
Fixes #117696-2
Fixes #118590
Fixes #122823
Fixes #131342
Fixes #139659
Analysis:
The causes of these issues are similar. They contain generic recursive functions that can be instantiated with different args infinitely at monomorphization stage.
Ideally this should be caught by the
check_recursion_limit
function. The reality is that normalization can reach recursion limit earlier than monomorphization's check because they calculate depths in different ways.Since normalization is called everywhere, ICEs appear in different locations.
Fix:
If we abort on overflow with
TypingMode::PostAnalysis
in the trait solver, it would also catch these errors.The main challenge is providing good diagnostics for them. So it's quite natural to put the check right before these normalization happening.
I first tried to check the whole MIR body's normalization and
references_error
. (As elaborate_drop handles normalization failure by returningty::Error
.)It turns out that checking all
Local
s seems sufficient.These types are gonna be normalized anyway. So with cache, these checks shouldn't be expensive.
This fixes these ICEs for both the next and old solver, though I'm not sure the change I made to the old solver is proper. Its overflow handling looks convoluted thus I didn't try to fix it more "upstream".