Skip to content
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

Optimized code generates valgrind errors #5856

Closed
brson opened this issue Apr 12, 2013 · 12 comments
Closed

Optimized code generates valgrind errors #5856

brson opened this issue Apr 12, 2013 · 12 comments
Labels
A-codegen Area: Code generation P-low Low priority

Comments

@brson
Copy link
Contributor

brson commented Apr 12, 2013

We are accumulating a lot of valgrind suppressions because of this: http://llvm.org/bugs/show_bug.cgi?id=12319

@thestinger
Copy link
Contributor

When Rust was zeroing everything (the stack segments and heap allocations), I think this check was always being masked so it was equivalent to having it disabled. I don't know the best way to deal with it, but I don't think disabling the class of error checking would be any worse than masking it with zeroing was.

@brson
Copy link
Contributor Author

brson commented Apr 12, 2013

@echristo from LLVM mentioned on IRC that he was looking into this issue. Hopefully upstream will have some guidance for us.

Disabling the 'jump depends on on uninitialized value' error in valgrind would significantly reduce the value of that tool.

@brson
Copy link
Contributor Author

brson commented Apr 13, 2013

I've pushed a commit that adds lots of suppressions. When this is resolved those should all be removed so they don't disguise errors.

brson added a commit to brson/rust that referenced this issue Apr 26, 2013
@catamorphism
Copy link
Contributor

Nominating for milestone 4, well-covered, since this affects our ability to use valgrind to its fullest extent.

@graydon
Copy link
Contributor

graydon commented Jul 25, 2013

Visiting for triage. I agree with the nomination. We should get this fixed someday!

@graydon
Copy link
Contributor

graydon commented Aug 22, 2013

accepted for well-covered milestone

@pnkfelix
Copy link
Member

Need not block 1.0. Assigning P-low.

@huonw
Copy link
Member

huonw commented Sep 9, 2014

This is still a problem, e.g. just running valgrind rustc generates:

==32331== Conditional jump or move depends on uninitialised value(s)
==32331==    at 0x5AAFF0B: driver::monitor::h67fd9ec99e612659CVF (in /usr/local/lib/librustc-4e7c5e5c.so)
==32331==    by 0x5AAFADE: driver::main_args::h758a33c73a229584LQE (in /usr/local/lib/librustc-4e7c5e5c.so)
==32331==    by 0x5B34BA5: main::ha773b68016fefe22HVM (in /usr/local/lib/librustc-4e7c5e5c.so)
==32331==    by 0x4E77792: start::closure.8433 (in /usr/local/lib/libnative-4e7c5e5c.so)
==32331==    by 0x65B449B: rust_try_inner (in /usr/local/lib/librustrt-4e7c5e5c.so)
==32331==    by 0x65B4485: rust_try (in /usr/local/lib/librustrt-4e7c5e5c.so)
==32331==    by 0x6558D32: unwind::try::hea1640d217ab7457H7d (in /usr/local/lib/librustrt-4e7c5e5c.so)
==32331==    by 0x6558B0E: task::Task::run::hb52aad40b24ebf23Ndd (in /usr/local/lib/librustrt-4e7c5e5c.so)
==32331==    by 0x4E77609: start::h020d729b3953296bsoe (in /usr/local/lib/libnative-4e7c5e5c.so)
==32331==    by 0x4E77448: lang_start::hde2f1b6d366575e3Lne (in /usr/local/lib/libnative-4e7c5e5c.so)
==32331==    by 0x689CB44: (below main) (libc-start.c:287)

I vaguely recall that this was due to enums, e.g. something handling an Option<u32> might branch based on None vs. Some in such a way that the u32 field gets read unconditionally; that is, that memory is read even when uninitialised in a None, but is irrelevant to the semantics of the code in this case. However, I cannot create a small testcase.

@thestinger
Copy link
Contributor

This isn't going to be fixed. It's a consequence of LLVM's optimized instruction scheduling and is entirely correct. They may provide a way to cripple the instruction scheduling to avoid this, but it wouldn't ever be a desired default for an optimized build. I don't think you'll find anyone interested in dealing with it because you might as well just flip on ASAN for Clang and GCC rather than -fno-valgrind-incompatible-optimizations.

@steveklabnik
Copy link
Member

Triage: @huonw 's valgrind rustc example still reproduces.

@Mark-Simulacrum
Copy link
Member

So I'm not quite sure what the status here is. @thestinger is correct as I understand it: this cannot be fixed without crippling LLVM's optimizations. So should this be closed?

@Mark-Simulacrum
Copy link
Member

Closing. This is an LLVM problem (and, AIUI, a general problem with optimizing code) -- valgrind doesn't handle this properly, and there's ~nothing we can do as I understand it.

flip1995 added a commit to flip1995/rust that referenced this issue Aug 11, 2020
…ip1995

Remove old Symbol reexport

I couldn't really tell what it was meant to improve. It seems more clear
without the renaming to `Name`?

changelog: none
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 11, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#5837 (needless_collect: catch x: Vec<_> = iter.collect(); x.into_iter() ...)
 - rust-lang#5846 (Handle mapping to Option in `map_flatten` lint)
 - rust-lang#5848 (Add derive_ord_xor_partial_ord lint)
 - rust-lang#5852 (Add lint for duplicate methods of trait bounds)
 - rust-lang#5856 (Remove old Symbol reexport)

Failed merges:

r? @ghost

changelog: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation P-low Low priority
Projects
None yet
Development

No branches or pull requests

8 participants