-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Bug in optimiser(maybe) #22008
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
Comments
Reduced test case: fn main() {
let command = "a";
match command {
"foo" => println!("foo"),
_ => println!("{}", command),
}
} This segfaults with |
This goes back to at least 0.12 - though it prints garbage values instead of segfaulting. 0.11 seems unaffected. |
I've done some hacky introspection. EDIT: turns out |
This has two parts. When I extended rustc to emit lifetime intrinsics, I chose to put a call to lifetime.end at the end of functions to mark arguments as dead that are passed by value on the stack. This allows LLVM to remove dead stores at the end of functions that it normally can't remove. This works because normally, the caller makes a copy of the value it passes in. Now, the call that match generates to compare the strings is to Question: Do we want to drop the lifetime.end call for by-value on-stack arguments, or fix the call to eq_slice to make copies? |
Work around rust-lang/rust#22008 (fixes #139)
just-a-bug; P-high, not 1.0 milestone. |
When matching against strings/slices, we call the comparison function for strings, which takes two string slices by value. The slices are passed in memory, and currently we just pass in a pointer to the original slice. That can cause misoptimizations because we emit a call to llvm.lifetime.end for all by-value arguments at the end of a function, which in this case marks the original slice as dead. So we need to properly create copies of the slices to pass them to the comparison function. Fixes rust-lang#22008
…tsakis When matching against strings/slices, we call the comparison function for strings, which takes two string slices by value. The slices are passed in memory, and currently we just pass in a pointer to the original slice. That can cause misoptimizations because we emit a call to llvm.lifetime.end for all by-value arguments at the end of a function, which in this case marks the original slice as dead. So we need to properly create copies of the slices to pass them to the comparison function. Fixes rust-lang#22008
Hi,
The rust optimiser or some other component is not behaving correctly resulting in wrong results.
I have produced a small example here : https://github.com/eklavya/rust-bug
This was reproduced on
Mac yosemite:
cargo 0.0.1-pre-nightly (2b9a3d6 2015-01-30 02:47:30 +0000)
rustc 1.0.0-nightly (3b2ed14 2015-02-03 14:56:32 +0000)
and
centos7 x64, rustc 1.0.0-nightly (706be5b 2015-02-05 23:14:28 +0000)
Please let me know if you need any more details.
The text was updated successfully, but these errors were encountered: