[PATCH] D59005: Fix memory leak in CreateSigAltStack

JF Bastien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 12:55:48 PST 2019


jfb added a comment.

This seems wrong. How is this point being reached twice? It's called from here:

  static void RegisterHandlers() { // Not signal-safe.
    // The mutex prevents other threads from registering handlers while we're
    // doing it. We also have to protect the handlers and their count because
    // a signal handler could fire while we're registeting handlers.
    static ManagedStatic<sys::SmartMutex<true>> SignalHandlerRegistrationMutex;
    sys::SmartScopedLock<true> Guard(*SignalHandlerRegistrationMutex);
  
    // If the handlers are already registered, we're done.
    if (NumRegisteredSignals.load() != 0)
      return;
  
    // Create an alternate stack for signal handling. This is necessary for us to
    // be able to reliably handle signals due to stack overflow.
    CreateSigAltStack();

Is the mutex wrong? It should ensure that the alt stack is only ever set up once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59005





More information about the llvm-commits mailing list