[libc-commits] [PATCH] D76676: [libc] Unblock SIGABRT before raising in abort

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Apr 3 09:41:17 PDT 2020


abrachet marked 2 inline comments as done.
abrachet added inline comments.


================
Comment at: libc/src/stdlib/abort.cpp:26
+  // it does not infinitely call itself.
+  static bool called;
+  if (!called) {
----------------
MaskRay wrote:
> The function-local variable is not needed. If the signal handler of SIGABRT is set to abort, the following blocking logic should work.
On MacOS
```lang=cpp
::signal(SIGABRT, +[] (int) { ::abort(); });
::abort();
```
This dies to SIGSEGV, presumably from a stack overflow. This is not ideal.


================
Comment at: libc/src/stdlib/abort.cpp:34
+  // interrupted by any async signals. The user handler will be run once we
+  // unblock if it was blocked previously.
+  sigset_t set;
----------------
MaskRay wrote:
> Another thread may concurrently install a signal handler for SIGABRT or unblock SIGABRT. There needs to be a lock.
Yes this was discussed, we need a recursive lock here but also in sigaction, we don't have those yet. I don't personally think the benefits are worth that complexity anyway though.


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

https://reviews.llvm.org/D76676





More information about the libc-commits mailing list