-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Revert change to stop zeroing the exchange heap #5047
Conversation
Ah, right. Will fix tomorrow. |
@brson: Here's a simpler test case that also triggers the issue:
Removing the |
Let me copy and paste my email to the core team: OK, I think I've figured it out. It seems to be a slightly sketchy, but harmless in this case, LLVM optimization. Here is the testcase:
(The error occurs in between 'vvv' and '^^^'). The conditional uninitialized branch occurs as part of inlined drop glue. Here is the annotated assembly:
So, as you can see, it is undefined whether the first branch (at _rust_main+449) is taken or not taken, but even if it isn't taken the second branch (at _rust_main+453) will always be taken, and it goes to the same spot. Thus we always end up at _rust_main+463 safely and don't try to free a wild pointer. In pseudocode, the compiler reordered "is the variant Some? if so, is the string pointer non-null?" into "is the string pointer non-null? if so, is the variant Some?" The answer to the question of whether the string pointer is non-null is undefined, since we didn't store anything there. But it doesn't matter because the code does nothing unless both conditions hold. The reason why strcat's change triggered this is that we started inlining glue, which triggered scalar replacement of aggregates and LLVM started performing more clever optimizations regarding tag discriminants and the ~str. Basically, LLVM promoted them to registers. (Notice how ~str stayed in r12 across basic blocks above.) Because it then saw SSA values and not memory it started reordering things. This isn't harmful, but it tipped off Valgrind. So yeah, this seems harmless. How to suppress it in valgrind is another story... Patrick |
LLVM bug 12319 seems to be about the same Valgrind issue. |
@sanxiyn thanks for finding that! |
…omatsakis This rather sprawling branch refactors the borrow checker and much of the region code, addressing a number of outstanding issues. I will close them manually after validating that there are test cases for each one, but here is a (probably partial) list: - #4903: Flow sensitivity - #3387: Moves in overloaded operators - #3850: Region granularity - #4666: Odd loaning errors - #6021: borrow check errors with hashmaps - #5910: @mut broken cc #5047 (take 5)
Don't trigger use_debug lint in Debug impl Fixes rust-lang#5039 changelog: Don't trigger [`use_debug`] lint in Debug impl
This fixes another valgrind problem, but still does not fix all the errors in rustdoc.