Open
Description
As a quick reproducer, compiling this code with the following flags should work fine unless -flto
is specified, in which case there should be termination due to an uncaught exception:
// clang -O2 test.cpp -fomit-frame-pointer -fuse-ld=lld
#include <cstdio>
// contrived magic function that uses traditional DWARF unwind data when combined with -fomit-frame-pointer on OSX
__attribute__((noinline)) int foo() {
int offset[70000];
asm volatile("":"+m"(offset)::);
throw 4;
}
int main() {
try {
foo();
} catch (...) {
printf("got it");
return 1;
}
return 4;
}
The actual bug was introduced in https://reviews.llvm.org/D136380 - the assignment of the file
pointer in order to map symbols to the original object file instead of the temporary monolithic LTO file causes the checks here and here to always fail. The former case never seems to be hit during LTO (should be fixed anyway though!), but the latter one is and thus causes exception metadata to never be emitted for functions that don't use compact unwind metadata.