[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 22:10:18 PST 2023


MaskRay added a comment.

I am unfamiliar with Clang codegen so I am just commenting about what a user may feel about this feature.

`compiler-rt/test/ubsan/TestCases/Misc/exception-escape.cpp` cannot demonstrate the value of the new UBSan check `-fsanitize=exception-escape`, as the executable will fail anyway (Clang emits `call` instead of `invoke` for a nounwind function call, and there is no LSDA information, libgcc/libunwind will call terminate; it's trivial to get more diagnostic with a SIBABRT signal handler).
To demonstrate the value, `footgun` and its caller need to be in different TUs and the caller does not know `footgun` is nounwind.
In such a setup, I think people likely care more about `-fno-exceptions`/`-fexceptions` exception propagation instead of `__attribute__((pure))` and find `-fsanitize=exception-escape` not do what it may advertise.

The more common `-fno-exceptions`/`-fexceptions` exception propagation dilemma can be detected today with `-fno-asynchronous-unwind-tables`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137381/new/

https://reviews.llvm.org/D137381



More information about the llvm-commits mailing list