[PATCH] D83372: Fix for memory leak reported by Valgrind

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 20:49:34 PDT 2020


dblaikie added a comment.

Having different behavior for tests V production worries me a bit.

How would people feel about this instead:

  static std::recursive_mutex *getManagedStaticMutex() {
    static std::recursive_mutex m;
    return &m;
  }

(& leave llvm_shutdown as-is)

No global ctor - lazily constructed. No global dtor... hmm, libstdc++ has a trivial dtor at least when I look at it one way (https://godbolt.org/z/ae6j7f) , but libc++'s is non-trivial.

Is the additional complexity worth saving this one global dtor? (assuming I'm even right that the approach I'm suggesting would address the issue under discussion in this review)

I certainly have some empathy for the consistency of avoiding all global ctors/dtors, but this one's a bit of a case of "who watches the watchmen" - can't really add another mutex to guard the initialization of this mutex. Could use atomic ops but that's tricky to get right/maintain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83372



More information about the llvm-commits mailing list