Repository navigation
Description
Updated summary:
Under some conditions, drops are generated if a previously moved value is reassigned. This was bisected to #39409.
In the following minimised code for example:
pub struct DropHasLifetime<'a>(&'a ());
impl<'a> ::std::ops::Drop for DropHasLifetime<'a> {
fn drop(&mut self) {}
}
fn move_and_return<T>(val: T) -> T {
val
}
struct Wrapper<'a>(DropHasLifetime<'a>);
fn main() {
static STATIC: () = ();
let mut wrapper = Wrapper(DropHasLifetime(&STATIC));
wrapper.0 = move_and_return(wrapper.0);
}wrapper.0 is dropped twice, see #42903 (comment) for complete mir.
-- Edited by @TimNN
Original Description:
There are now 3 instances of strange crashes/segfaults/hangs/error messages that happen using nightly 2017-06-20 (or it might be 2017-06-19) that don't happen with rustc 1.19.0-beta.2 (a175ee5 2017-06-15) reported on this reddit thread.
I wanted to start an issue for discussing and investigating this because I think it's clear there's something wrong, but I apologize that we haven't yet gotten an isolated reproduction. I also don't know if these cases are the same bug or different bugs yet, please let me know if I should split this out into more issues.
Or perhaps these already have issues! I didn't see any reported issues that looked similar enough to these and in the right time frame :-/
Incident 1 - unit tests crashing with "error: An unknown error occurred"
Via reddit user fulmicoton:
My unit tests have been crashing since rustc 1.19.0-nightly (0414594 2017-06-19) on MacOS.
Previous version do not crash. Later versions do crash with "error: An unknown error occurred"
My project is quite large and contains unsafe code, so this could be a bug that got surfaced by a change in the compiler.
Will ask if they can share more details.
Incident 2 - crates.io's tests (at least one in particular)
Described in pull request rust-lang/crates.io#795, but I'm seeing weirdness on master too. All tests are passing using stable Rust on crates.io master.
On Wednesday, @jtgeibel was seeing one of cargo's tests (krate::index_queries) intermittently segfaulting and crashing with (signal: 4, SIGILL: illegal instruction)
On master, I'm seeing the tests fail in a really really bizarre way: it looks like serialized JSON is being corrupted???? The test is making a request to the crates.io server, which returns JSON, and then the test attempts to deserialize the JSON and make assertions on it. The JSON returned by the server is valid JSON, but one of the keys looks like it's set to the value of the beginning of the JSON???? Here's the output that won't deserialize, pretty-printed and a bunch of stuff that looks fine removed to make the problem more obvious, also with comments that I've added here even though JSON doesn't have comments:
{
"crates": [
{
// removed lots of stuff in here that looks fine
"name": "BAR_INDEX_QUERIES",
"repository": null,
"versions": null,
"{\"crates\":": "2017-06-25T16:06:06Z" // <- LOOK AT THIS KEY
},
{
// removed lots of stuff in here that looks fine
"name": "foo_index_queries",
"owner_tea": 0,
"repository": null,
"updated_at": "2017-06-25T16:06:06Z", // <- THE WEIRD KEY ABOVE SHOULD LOOK LIKE THIS, this is a good result in the same request response though!!!!
"versions": null
}
],
To reproduce:
- Check out and set up crates.io (involves installing postgres, sorry sorry, if this is too complex, I am happy to run experiments/patches on my setup)
- On master, run
cargo test krate::index_queries. You've reproduced the problem if you see:
running 1 test
test krate::index_queries ... FAILED
failures:
---- krate::index_queries stdout ----
thread 'krate::index_queries' panicked at 'failed to decode: MissingFieldError("updated_at")
{"crates":[{"badges":[],"categories":null,"description":null,"documentation":null,"downloads":0,"exact_match":false,"homepage":null,"id":"BAR_INDEX_QUERIES","keywords":null,"license":null,"links":{"owner_team":"/api/v1/crates/BAR_INDEX_QUERIES/owner_team","owner_user":"/api/v1/crates/BAR_INDEX_QUERIES/owner_user","owners":"/api/v1/crates/BAR_INDEX_QUERIES/owners","reverse_dependencies":"/api/v1/crates/BAR_INDEX_QUERIES/reverse_dependencies","version_downloads":"/api/v1/crates/BAR_INDEX_QUERIES/downloads","versions":"/api/v1/crates/BAR_INDEX_QUERIES/versions"},"max_version":"0.99.0","name":"BAR_INDEX_QUERIES","repository":null,"versions":null,"{\"crates\":":"2017-06-25T16:16:04Z"},{"badges":[],"categories":null,"created_at":"2017-06-25T16:16:04Z","description":"description","documentation":null,"exact_match":false,"homepage":null,"id":"foo_index_queries","keywords":null,"license":null,"links":{"owner_team":"/api/v1/crates/foo_index_queries/owner_team","owner_user":"/api/v1/crates/foo_index_queries/owner_user","owners":"/api/v1/crates/foo_index_queries/owners","reverse_dependencies":"/api/v1/crates/foo_index_queries/reverse_dependencies","version_downloads":"/api/v1/crates/foo_index_queries/downloads","versions":"/api/v1/crates/foo_index_queries/versions"},"max_version":"0.99.0","name":"foo_index_queries","owner_tea":0,"repository":null,"updated_at":"2017-06-25T16:16:04Z","versions":null}],"meta":{"total":2}}', src/tests/all.rs:169
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
krate::index_queries
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 101 filtered out
- If I check out the changes in Switch several category routes over to diesel crates.io#795 and run
cargo test krate::index_queries --verbose, I alternately get a failure that looks like:
running 1 test
NOTICE: text-search query doesn't contain lexemes: ""
NOTICE: text-search query doesn't contain lexemes: ""
NOTICE: text-search query doesn't contain lexemes: ""
test krate::index_queries ... FAILED
failures:
---- krate::index_queries stdout ----
thread 'krate::index_queries' panicked at 'assertion failed: `(left == right)` (left: `0`, right: `1`)', src/tests/krate.rs:171
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
krate::index_queries
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 98 filtered out
and a crash that looks like:
running 1 test
error: process didn't exit successfully: `/Users/carolnichols/rust/crates.io/target/debug/deps/all-f4f07d01d0cee92f krate::index_queries` (signal: 11, SIGSEGV: invalid memory reference)
Incident 3 - trust-dns
Via @bluejekyll, see their description on this issue: bluejekyll/trust-dns#152
To reproduce:
- Check out https://github.com/bluejekyll/trust-dns
- Run
cargo test test_nsec_query_example_nonet
Activity
TimNN commentedon Jun 25, 2017
The
trust-dnsregression was introduced by #39409 according to @Mark-Simulacrum's awesomebisect-rust.Mark-Simulacrum commentedon Jun 25, 2017
cc @pnkfelix -- regression due to #39409
bluejekyll commentedon Jun 25, 2017
Woh. I need to read about that tool, that's awesome!
BTW, I tried to clarify in the bug report on the trust-dns repo; it's not that OpenSSL and ring are affected, it's that I reproduced the issue with both OpenSSL and/or ring dependencies in use.
carols10cents commentedon Jun 25, 2017
Thanks @bluejekyll ! I've changed my description to just reference your bug and not duplicate what your description used to be :)
TimNN commentedon Jun 25, 2017
Running the
trust-dnstest under GDB I get:When running all tests in the binary: a segmentation fault in jemalloc (Edit: reproduced with the system allocator as well):
When filtering by the given test name:
Edit: Here are some valgrind logs, they look... worrisome https://gist.github.com/TimNN/039cefc6cfe601faa1d129398583fd39
bluejekyll commentedon Jun 25, 2017
If you want to take OpenSSL out of the picture, I believe the same issue can be triggered with openssl disabled:
cargo test --no-default-features --features=ring
fulmicoton commentedon Jun 25, 2017
Incident 1 mentionned in this bug description is in tantivy. I tried to trim down the unit test to something simpler, smaller that stills fails without success. Introducing a single print statement is enough for the bug to disappear. The code does contain a lot of unsafe calls so this is probably a bad example to investigate.
In case this is still useful,
termdict::tests::test_stream_range_boundariesintantivy's master branch fails consistently.The backtrace is as follows
sfackler commentedon Jun 25, 2017
One debugging step that might help is to switch over to the system allocator, which has better runtime corruption checks, and then maybe run in valgrind.
fulmicoton commentedon Jun 26, 2017
Following @sfackler advise, I used the system allocator. The failure happens when deallocating a
Vec<u8>buffer.withoutboats commentedon Jun 26, 2017
petgraph has been failing recently, not sure if its the same regression
TimNN commentedon Jun 26, 2017
I switched
trust-dnsto the system allocator and indeed got much "better" / more precise valgrind results: https://gist.github.com/TimNN/5e77b22b795b9a28fb44d9349c197ad8Looking at the logs, I believe the bad codegen happens in this code:
As far as I can tell, the problem is that
vecin the third case is dropped in thensec_info =line despite being moved a bit further up.11 remaining items
TimNN commentedon Jun 26, 2017
It appears as if
ElaborateDropsgot confused by #39409: Consider the following diffs from a good rustc to a bad rustc: https://gist.github.com/TimNN/717d3b64f7a461ec459a1944b88989c0:Before
ElaborateDropsthey are almost identical however afterwards there is a bad drop.Edit: The gist now includes the diff for
EraseRegions: Some lifetimes are apparently no longer correctly erased.TimNN commentedon Jun 26, 2017
I tried to make some sense of the debug logs, here is an excerpt:
Judging by the doc comment on
MovePaththemp8andmp9paths seem to be "bad", with both referring to the same thing.arielb1 commentedon Jun 26, 2017
I'll take this.
nikomatsakis commentedon Jun 27, 2017
@arielb1 this seems pretty important to track down; if you don't have time, do raise the bat signal.
re-add the call to `super_statement` in EraseRegions
Auto merge of #42931 - arielb1:statement-visitor, r=eddyb
erase types in the move-path abstract domain
Rollup merge of rust-lang#43512 - arielb1:untyped-move-paths, r=eddyb
Rollup merge of rust-lang#43512 - arielb1:untyped-move-paths, r=eddyb