Page MenuHomePhabricator

Handle UNW_X86_64_RIP in Registers_x86_64
Needs ReviewPublic

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

Details

Reviewers
jfb
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.