Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libunwind Defer acquiring the FDE lock until after t...



details:   https://anonhg.NetBSD.org/src/rev/de381abb7997
branches:  trunk
changeset: 953200:de381abb7997
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sun Feb 28 23:12:37 2021 +0000

description:
Defer acquiring the FDE lock until after the allocation. This can avoid
nesting issues between malloc and backtrace when using LSan.

diffstat:

 sys/lib/libunwind/AddressSpace.hpp |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (19 lines):

diff -r 6d9f67afda9c -r de381abb7997 sys/lib/libunwind/AddressSpace.hpp
--- a/sys/lib/libunwind/AddressSpace.hpp        Sun Feb 28 22:12:16 2021 +0000
+++ b/sys/lib/libunwind/AddressSpace.hpp        Sun Feb 28 23:12:37 2021 +0000
@@ -283,7 +283,6 @@
   }
 
   bool addFDE(pint_t pcStart, pint_t pcEnd, pint_t fde) {
-    pthread_rwlock_wrlock(&fdeTreeLock);
     Range *n = (Range *)malloc(sizeof(*n));
     n->hdr_base = fde;
     n->hdr_start = 0;
@@ -292,6 +291,7 @@
     n->last_pc = pcEnd;
     n->data_base = 0;
     n->ehframe_base = 0;
+    pthread_rwlock_wrlock(&fdeTreeLock);
     if (static_cast<Range *>(rb_tree_insert_node(&segmentTree, n)) == n) {
       pthread_rwlock_unlock(&fdeTreeLock);
       return true;



Home | Main Index | Thread Index | Old Index