-
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
Reference outlives the value it points to (segfault) #37418
Comments
This looks like #18937 Trait definition: https://github.com/benschulz/object-store-rs/blob/7d6ecea8a1700de2c9dfe8ebb148e58c7265cac7/src/store.rs#L153 Function with more restrictive lifetimes: https://github.com/benschulz/object-store-rs/blob/7d6ecea8a1700de2c9dfe8ebb148e58c7265cac7/src/store.rs#L167 FYI, while looking through your code, I noticed https://github.com/benschulz/orc/blob/320651873e964eefd79d360adf7f3b4bba7dfb7c/src/lib.rs#L150. Transmuting an immutable reference into a mutable reference is never considered safe. |
I subscribed to #18937 and will check once its resolved. |
A is value referenced both outside as well as inside a closure and the closure is boxed and (indirectly) returned. A segfault is raised when the closure is eventually invoked and the reference dereferenced.
I tried this code:
I failed to create an SSCEE for the bug, however, I originally stumbled over the behaviour here. Semantically the code contains the same error as the following code.
I expected to see this happen: The compiler should force me to mark the closure as move and resolve the resulting errors as it does with the small example given above.
Instead, this happened: The code compiles as is and segfaults when the test is run (simply via
cargo test
ing the repo). The segfault happens when dereferencingexpected_key2
inside the closure. It does not occur when marking the closure asmove
and passing&*expected_key
instead of&*expected_key2
tostore.write_blob
.Meta
rustc --version --verbose
:rustc 1.12.1 (d4f3940 2016-10-19)
binary: rustc
commit-hash: d4f3940
commit-date: 2016-10-19
host: x86_64-unknown-linux-gnu
release: 1.12.1
Backtrace (from gdb):
The text was updated successfully, but these errors were encountered: