This is an archive of the discontinued LLVM Phabricator instance.

Handle UNW_X86_64_RIP in Registers_x86_64
ClosedPublic

Authored by laplab on Aug 23 2019, 2:12 PM.

Details

Reviewers
jfb
MaskRay
Group Reviewers
Restricted Project
Summary

We use LLVM libunwind in query profiler of 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.

Diff Detail

Repository
rUNW libunwind

Event Timeline

laplab created this revision.Aug 23 2019, 2:12 PM
laplab created this object with edit policy "Administrators".

I don't know that code, however it does look strange to me that we have both UNW_X86_64_RIP and UNW_REG_IP to represent rip in the first place.

I can't add reviewers myself for some reason, but I think @mstorsjo would be a good start to look at this based on prior commit history.

I don't really know this either, but @compnerd and/or @rnk might. It looks straightforward, but I don't know if the rip register is special somehow in dwarf.

@joerg might also know

It would be interesting to get an actual backtrace. It should not be a DWARF register number, but it might be from a direct caller of the unw interface.

We are also running into this issue when building YugabyteDB with Clang 12 with AddressSanitizer instrumentation enabled: https://github.com/yugabyte/yugabyte-db/issues/7092

ldionne added a reviewer: Restricted Project.Sep 23 2021, 9:36 AM

Fixed by D107919, closing

MaskRay accepted this revision as: MaskRay.Sep 23 2021, 10:07 AM
This revision is now accepted and ready to land.Sep 23 2021, 10:07 AM
MaskRay closed this revision.Sep 23 2021, 10:07 AM