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

debuginfo: Assertion in ValueHandleBase::ValueIsDeleted() when using -O #9993

Closed
michaelwoerister opened this issue Oct 21, 2013 · 2 comments
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)

Comments

@michaelwoerister
Copy link
Member

Sometimes when enabling debug info and optimizations at the same time, rustc dies with an assertion in the LLVM method ValueHandleBase::ValueIsDeleted():

While deleting: metadata %
An asserting value handle still pointed to this value!
UNREACHABLE executed at /home/sc/projects/rust/rust/src/llvm/lib/IR/Value.cpp:632!

This is one the major issues keeping debug info from being end-user ready (see #9770).

I was already able to identify the cause for the assertion:
The failure itself says that a value handle still points to the metadata node that is currently being deleted. This leaked handle is created in LLVM's DwarfDebug::collectDeadVariables() on a path that is only hit with optimizations activated. That's why the assertion is never triggered when compiling something without the -O flag.

The memory leak occurs because the method cannot handle duplicate entries in the list of subprograms in the compile unit. This is a bug in LLVM: http://llvm.org/bugs/show_bug.cgi?id=16017
It's not clear yet how it will be fixed exactly.

But the issue should also be tackled on our side: That LLVM reacts with a memory leak to invalid input is unfortunate but it's still us that generate the invalid input. The main issue here is that some functions are translated more than once (see issue #7349) and thus they are also added to the debug info function list more than once.

I think the best way to fix this issue is to fix #7349. This way we don't have to wait for LLVM to take care of their side. Also, the folks at LLVM might decide to just assert on invalid input, so we have take care of this anyway.

@michaelwoerister
Copy link
Member Author

A little update on this: The actual memory leak has been fixed in LLVM (with this change: llvm-mirror/llvm@d56c9db) and the assertion should thus not be triggered any more, once we use a new version of LLVM.

It's still a problem/code smell that the same function is translated more than once. It's easy enough to fix this on the debug info side (just keep track of which functions have been handled already and skip otherwise) but I guess it would be better to fix the underlying issue (#7349).

@michaelwoerister
Copy link
Member Author

I'm closing this issue because it doesn't occur anymore---the memory corruption in LLVM has been fixed. I just left it open because there is also a related (non-debuginfo) issue on the rustc-side, but this issue is already documented properly in #7349. Having a second issue as reminder is redundant.

flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 29, 2022
fix rust-lang#9993
changlog: [`match_wildcard_for_single_variants`] avoid suggestion on wildcard with guard
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 29, 2022
Avoid `match_wildcard_for_single_variants` on guarded wild matches

fix rust-lang#9993

changelog: FP: [`match_wildcard_for_single_variants`]: No longer lints on wildcards with a guard
[rust-lang#10056](rust-lang/rust-clippy#10056)
<!-- changelog_checked -->

r? `@Jarcho`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.)
Projects
None yet
Development

No branches or pull requests

1 participant