[libunwind] dde26e3 - [libunwind][AIX] Call dlclose only when dlsym() fails (#112768)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 19 15:41:10 PDT 2024
Author: Xing Xue
Date: 2024-10-19T18:41:06-04:00
New Revision: dde26e361f50df4b999ac117222c74f2c100f817
URL: https://github.com/llvm/llvm-project/commit/dde26e361f50df4b999ac117222c74f2c100f817
DIFF: https://github.com/llvm/llvm-project/commit/dde26e361f50df4b999ac117222c74f2c100f817.diff
LOG: [libunwind][AIX] Call dlclose only when dlsym() fails (#112768)
The personality routine `__xlcxx_personality_v0` in `libc++abi` is
hard-coded in the unwinder as the handler for EH in applications
generated by the legacy IBM C++ compiler. The symbol is resolved
dynamically using `dlopen` to avoid a hard dependency of `libunwind` on
`libc++abi` for cases such as non-C++ applications. However, `dlclose`
was incorrectly called after `dlsym` succeeded, potentially invalidating
the function pointer obtained from `dlsym` when the memory allocated for
the `dlopen` is reclaimed. This PR changes to call `dlclose` only when
`dlsym` fails.
Added:
Modified:
libunwind/src/UnwindCursor.hpp
Removed:
################################################################################
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 2a3aba28fb6ca5..32e6fb43d988ff 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -2150,9 +2150,9 @@ bool UnwindCursor<A, R>::getInfoFromTBTable(pint_t pc, R ®isters) {
dlsym(libHandle, "__xlcxx_personality_v0"));
if (xlcPersonalityV0 == NULL) {
_LIBUNWIND_TRACE_UNWINDING("dlsym() failed with errno=%d\n", errno);
+ dlclose(libHandle);
assert(0 && "dlsym() failed");
}
- dlclose(libHandle);
errno = saveErrno;
}
xlcPersonalityV0InitLock.unlock();
More information about the cfe-commits
mailing list