Skip to content

Commit dde26e3

Browse files
authored
[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.
1 parent 2eb1699 commit dde26e3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libunwind/src/UnwindCursor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,9 +2150,9 @@ bool UnwindCursor<A, R>::getInfoFromTBTable(pint_t pc, R &registers) {
21502150
dlsym(libHandle, "__xlcxx_personality_v0"));
21512151
if (xlcPersonalityV0 == NULL) {
21522152
_LIBUNWIND_TRACE_UNWINDING("dlsym() failed with errno=%d\n", errno);
2153+
dlclose(libHandle);
21532154
assert(0 && "dlsym() failed");
21542155
}
2155-
dlclose(libHandle);
21562156
errno = saveErrno;
21572157
}
21582158
xlcPersonalityV0InitLock.unlock();

0 commit comments

Comments
 (0)