https://github.com/xingxue-ibm updated 
https://github.com/llvm/llvm-project/pull/112768
>From 2bb223edb6a3a7766606f5c7e6c0aa3fa3e09a63 Mon Sep 17 00:00:00 2001
From: Xing Xue <xing...@outlook.com>
Date: Thu, 17 Oct 2024 14:59:40 -0400
Subject: [PATCH 1/2] Call dlclose() only when dlsym() fails.

---
 libunwind/src/UnwindCursor.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 2a3aba28fb6ca5..9f3ffd19e1746a 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2151,8 +2151,8 @@ bool UnwindCursor<A, R>::getInfoFromTBTable(pint_t pc, R 
&registers) {
         if (xlcPersonalityV0 == NULL) {
           _LIBUNWIND_TRACE_UNWINDING("dlsym() failed with errno=%d\n", errno);
           assert(0 && "dlsym() failed");
+          dlclose(libHandle);
         }
-        dlclose(libHandle);
         errno = saveErrno;
       }
       xlcPersonalityV0InitLock.unlock();

>From 96a9ca99969675c0940493344970d321aa421b2d Mon Sep 17 00:00:00 2001
From: Xing Xue <xing...@outlook.com>
Date: Thu, 17 Oct 2024 15:45:33 -0400
Subject: [PATCH 2/2] Fix the location of dlclose.

---
 libunwind/src/UnwindCursor.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 9f3ffd19e1746a..32e6fb43d988ff 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2150,8 +2150,8 @@ bool UnwindCursor<A, R>::getInfoFromTBTable(pint_t pc, R 
&registers) {
             dlsym(libHandle, "__xlcxx_personality_v0"));
         if (xlcPersonalityV0 == NULL) {
           _LIBUNWIND_TRACE_UNWINDING("dlsym() failed with errno=%d\n", errno);
-          assert(0 && "dlsym() failed");
           dlclose(libHandle);
+          assert(0 && "dlsym() failed");
         }
         errno = saveErrno;
       }

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to