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

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 13 18:18:32 PST 2022


MaskRay added a comment.

I think improving diagnostic is useful but `-fsanitize=` is probably not a good place. Instrumenting call sites with `callq   __ubsan_handle_exception_escape at PLT` wastes code size. The functionality is better handled somewhere in libc++abi personality related code with possible improvement to exception handling related LLVM IR.

  void bar(); void foo() { bar(); }

`clang++ -fno-exceptions -fsanitize=exception-escape -c b.cc` does not instrument the potentially-throwing-and-propagating `bar()` so an error cannot be caught.
However, for `-fno-exceptions` code, instrumenting every call site is going to greatly increase code size and suppress optimizations.

I wish that I capture the compiler and runtime behavior well in https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#compiler-behavior. https://discourse.llvm.org/t/catching-exceptions-while-unwinding-through-fno-exceptions-code/57151 is a proposal to improve the diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381



More information about the cfe-commits mailing list