Issue 135888
Summary [lld] Non-compact (DWARF) unwind data emission is broken on MacOS
Labels miscompilation, lld:MachO
Assignees
Reporter duk-37
    As a quick reproducer, compiling this code with the following flags and `-flto` should cause termination due to an uncaught exception:

```cpp
// 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](https://github.com/llvm/llvm-project/blob/0b8f817aab7a242e0bfb519cb07c8979ffadef36/lld/MachO/InputFiles.cpp#L1166) and [here](https://github.com/llvm/llvm-project/blob/0b8f817aab7a242e0bfb519cb07c8979ffadef36/lld/MachO/InputFiles.cpp#L1490) to always fail. The former cases never seems to be hit during LTO, but the latter one is and thus causes exception metadata to never be emitted for functions that don't use compact unwind metadata.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to