-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Description
A while back, our toolchain shortly moved the Rust compiler ahead of our clang distribution. As a result LTO bitcode from rustc was used in an older LLD. While we don't expect this to be supported (its definitely wrong and we've taken steps to ensure that doesn't happen again), it did crash LLD in the LTO pipeline and trigger an assert in a asserts enabled builds. Our sole contention is that we don't think LLVM should crash because the bitcode was incompatible. Fatal errors or some other failure mechanism would be preferable.
#147260 introduced the bitcode change that caused the incompatibility. In our opinion this isn't a problem w/ their patch, but rather the failure mechanism in the LTO pipeline and/or the detection mechanisms available for incompatible IR versioning.
Error:
ld.lld: /usr/local/google/home/paulkirth/llvm-fork/llvm/lib/Bitcode/Reader/MetadataLoader.cpp:349: (anonymous namespace)::(anonymous namespace)::PlaceholderQueue::~PlaceholderQueue(): Assertion `empty() && "PlaceholderQueue hasn't bee
n flushed before being destroyed"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
#0 0x00005615294ee7b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /usr/local/google/home/paulkirth/llvm-fork/llvm/lib/Support/Unix/Signals.inc:804:13
[1] 4027137 IOT instruction (core dumped) ~/llvm-fork/build/bin/ld.lld @response.txt
Linker reproducer: https://g-issues.fuchsia.dev/action/issues/430381743/attachments/68029508?download=true
Looking at the assertion failure, and stepping through this in a debugger, the "fix" could just to be throw a fatal error in the destructor of PlaceHolderQueue if it isn't empty (turn the assertion into an error). That doesn't sound to me like a great solution, but would probably work for cases like this, where there is new metadata and it won't be handled here.
Does anyone have an idea of a better way to detect this class of problem? or at least prevent this kind of crash the next time bitcode formatting has an update? To be clear I don't think we should go out of our way to try and support this situation, I just don't think out toolchain should crash if we can avoid it. This is an attempt my attempt to try and avoid it, but I'm fine if we think this is too much work.