-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Fix ICE in v0 symbol mangling for deeply nested generic types #155122
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
Closed
GokhanKabar
wants to merge
1
commit into
rust-lang:main
from
GokhanKabar:fix-ice-symbol-mangling-deeply-nested-generics
+39
−1
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| //@ build-pass | ||
| //@ compile-flags: -C symbol-mangling-version=v0 | ||
|
|
||
| struct D; | ||
|
|
||
| type O0<T> = Option<T>; | ||
| type O1<T> = O0<T>; | ||
| type O2<T> = O1<O1<T>>; | ||
| type O3<T> = O2<O2<T>>; | ||
| type O4<T> = O3<O3<T>>; | ||
| type O5<T> = O4<O4<T>>; | ||
| type O6<T> = O5<O5<T>>; | ||
| type O7<T> = O6<O6<T>>; | ||
| type O8<T> = O7<O7<T>>; | ||
| type Q510<T> = O8<O7<O6<O5<O4<O3<O2<T>>>>>>>; | ||
|
|
||
| fn f<T>() {} | ||
| fn describe<T>() { | ||
| f::<Q510<T>>() | ||
| } | ||
|
|
||
| fn main() { | ||
| describe::<D>(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
View changes since the review
This means we do thr fairly expensive demangling on every mangle and fall back to hashing even for bugs
Also, is there any previous discussion with maintainers about this?
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 investigated an alternative: tracking nesting depth inside
V0SymbolManglerduringprint_type. Unfortunately this doesn't work because the depth experienced byrustc_demangleis not the same as the call-stack depth during mangling backref following in the demangler adds recursion that isn't tracked in the mangler. A symbol that only reaches depth ~300 inprint_typecan still exceed the 500-level limit in the demangler due to backrefs. Sotry_demangleis the only reliable way to detect this.Regarding hiding bugs: the
debug_assert!at the end ofcompute_symbol_name(line 331) still validates the final symbol (including hashed fallback) in debug builds, so actual v0 mangling bugs producing invalid symbols would still be caught there.I'm not aware of prior maintainer discussion on this approach this is the initial fix.
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.
How is the final symbol validation relevant when you take any error here and turn it into a hashed symbol?
Uh oh!
There was an error while loading. Please reload this page.
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.
yeah that point doesn't make sense