[libcxx-commits] [PATCH] D131292: [libunwind][AIX] Save/restore errno before/after system calls dlopen/dlsym/dlclose

Xing Xue via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 8 14:22:39 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc8edbea7a5f: [libunwind][AIX] Save/restore errno before/after system calls… (authored by xingxue).

Changed prior to commit:
  https://reviews.llvm.org/D131292?vs=450845&id=450949#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131292

Files:
  libunwind/src/UnwindCursor.hpp


Index: libunwind/src/UnwindCursor.hpp
===================================================================
--- libunwind/src/UnwindCursor.hpp
+++ libunwind/src/UnwindCursor.hpp
@@ -2106,6 +2106,11 @@
           // using dlopen().
           const char libcxxabi[] = "libc++abi.a(libc++abi.so.1)";
           void *libHandle;
+          // The AIX dlopen() sets errno to 0 when it is successful, which
+          // clobbers the value of errno from the user code. This is an AIX
+          // bug because according to POSIX it should not set errno to 0. To
+          // workaround before AIX fixes the bug, errno is saved and restored.
+          int saveErrno = errno;
           libHandle = dlopen(libcxxabi, RTLD_MEMBER | RTLD_NOW);
           if (libHandle == NULL) {
             _LIBUNWIND_TRACE_UNWINDING("dlopen() failed with errno=%d\n",
@@ -2119,6 +2124,7 @@
             assert(0 && "dlsym() failed");
           }
           dlclose(libHandle);
+          errno = saveErrno;
         }
       }
       xlcPersonalityV0InitLock.unlock();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131292.450949.patch
Type: text/x-patch
Size: 1048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220808/b1f2bb21/attachment.bin>


More information about the libcxx-commits mailing list