-
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
Segfault (use-after-free) in ty::lookup_field_type when pattern-matching structs #3215
Comments
here is disassembly that shows where the first invalid read is: http://pastebin.mozilla.org/1760806 |
I wonder if we ought to back out any snapshots that have been taken since the new struct syntax was introduced, if that's really what it is. I wouldn't trust any code compiled with arbitrary values read from the heap. |
Do we have any idea what the bug is, really? |
I had a use after free bug the other day that was related to moving out of an enum doing the wrong thing. I don't know if that would be at all related here though. |
this reminds me of the use after free we ran into in icfp when using eric's unsafe @eholk what was it? maybe rustc is doing the same thing. |
The first use-after-free comes on the line |
Found the root of it. In
And then later:
This shouldn't have compiled. Or maybe it should have, and the |
actually, I think this is the question that @graydon and I have been wrestling with. borrowck right now permits rvalues to live longer than you might expect---up to the surrounding fn or loop, but I don't think trans respects it (as I mentioned). The question is, who is wrong? I was going to go and patch up trans, but perhaps the bug is that borrowck is too liberal. |
minimized test case - valgrind reports this also does a use-after-free:
|
Opened #3217 so I can close this one with a workaround. |
…flip1995 Fix FP for `suspicious_arithmetic_impl` from `suspicious_trait_impl` … As discussed in rust-lang#3215, the `suspicious_trait_impl` lint causes too many false positives, as it is complex to find out if binary operations are suspicious or not. This PR restricts the number of binary operations to at most one, otherwise we don't lint. This can be seen as very conservative, but at least FP can be reduced to bare minimum. Fixes: rust-lang#3215 changelog: limit the `suspicious_arithmetic_impl` lint to one binop, to avoid many FPs
allow to run a rustfmt command from cargo-fmt even when there is no target
`lazy_cell` became stable: rust-lang#121377. `vtable_ptr` is renamed to `_vtable_ptr`: rust-lang@d83f3ca8ca. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
In very lucky situations (dependent on file size, file name, comments, compiler flags), when compiling a struct pattern, rustc will segfault outright. In all situations, it will use-after-free.
Run rustc under valgrind on this code:
You should see:
The text was updated successfully, but these errors were encountered: