[libcxx-commits] [PATCH] D66685: Handle UNW_X86_64_RIP in Registers_x86_64

Nikita Lapkov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 23 14:13:35 PDT 2019

laplab created this revision.
laplab created this object with edit policy "Administrators".
Herald added a reviewer: jfb.
Herald added subscribers: libcxx-commits, ldionne.

We use LLVM libunwind in query profiler of ClickHouse <https://github.com/yandex/ClickHouse> DBMS.

Basically server is interrupted by signal with high frequency and libunwind API is called in signal handler. During the development we noticed that at random time points server aborts with message:

  libunwind: getRegister ../contrib/libunwind/src/Registers.hpp:379 - unsupported x86_64 register

Further investigation with gdb has shown that libunwind tries to get register #16 (numeration starts from zero) which is RIP on x86_64.
We have tried to localise the problem and provide a minimum example, but there were no pattern in these errors.
After reading some code around `Registers.hpp` it turned out that `UNW_X86_64_RIP` is not handled in switches of `Registers_x86_64` which we believe is a problem. This diff adds handling of this option.
We have applied this change to our fork of libunwind and error has never repeated again.

  rUNW libunwind



Index: src/Registers.hpp
--- src/Registers.hpp
+++ src/Registers.hpp
@@ -332,7 +332,7 @@
     return true;
   if (regNum < 0)
     return false;
-  if (regNum > 15)
+  if (regNum > 16)
     return false;
   return true;
@@ -375,6 +375,8 @@
     return _registers.__r14;
   case UNW_X86_64_R15:
     return _registers.__r15;
+  case UNW_X86_64_RIP:
+    return _registers.__rip;
   _LIBUNWIND_ABORT("unsupported x86_64 register");
@@ -435,6 +437,9 @@
   case UNW_X86_64_R15:
     _registers.__r15 = value;
+  case UNW_X86_64_RIP:
+    _registers.__rip = value;
+    return;
   _LIBUNWIND_ABORT("unsupported x86_64 register");
@@ -477,6 +482,8 @@
     return "r14";
   case UNW_X86_64_R15:
     return "r15";
+  case UNW_X86_64_RIP:
+    return "rip";
   case UNW_X86_64_XMM0:
     return "xmm0";
   case UNW_X86_64_XMM1:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66685.216950.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190823/e14ee118/attachment-0001.bin>

More information about the libcxx-commits mailing list