Skip to content

Handle x64 linux signal trampoline without relying on DWARF unwind info #32

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

al13n321
Copy link
Member

@al13n321 al13n321 commented Aug 9, 2024

Same thing that libunwind already does for ARM, RISK V, and S390X.

Tested it with musl (modified to produce .eh_frame).

Before:

2024.08.06 20:12:34.470414 [ 3269296 ] {} <Fatal> ClientBase: 0.0. inlined from ./build/./src/Common/StackTrace.cpp:349: StackTrace::tryCapture()                                                                                                                                     
2024.08.06 20:12:34.470447 [ 3269296 ] {} <Fatal> ClientBase: 0. ./build/./src/Common/StackTrace.cpp:318: StackTrace::StackTrace(ucontext const&) @ 0x000000000bca7588                                                                                                                
2024.08.06 20:12:34.490829 [ 3269296 ] {} <Fatal> ClientBase: 1. ./build/./src/Common/SignalHandlers.cpp:83: signalHandler(int, siginfo_t*, void*) @ 0x000000000bf046d0

After:

2024.08.09 00:08:20.838647 [ 3389953 ] {} <Fatal> ClientBase: 0.0. inlined from ./build/./src/Common/StackTrace.cpp:349: StackTrace::tryCapture()
2024.08.09 00:08:20.838685 [ 3389953 ] {} <Fatal> ClientBase: 0. ./build/./src/Common/StackTrace.cpp:318: StackTrace::StackTrace(ucontext const&) @ 0x000000000bca7588
2024.08.09 00:08:20.859259 [ 3389953 ] {} <Fatal> ClientBase: 1. ./build/./src/Common/SignalHandlers.cpp:83: signalHandler(int, siginfo_t*, void*) @ 0x000000000bf046d0
2024.08.09 00:08:20.861179 [ 3389953 ] {} <Fatal> ClientBase: 2. src/signal/x86_64/restore.s:6: __restore_rt @ 0x0000000016850769
2024.08.09 00:08:20.862485 [ 3389953 ] {} <Fatal> ClientBase: 3. src/thread/__syscall_cp.c:11: sccp @ 0x000000001685c5e8
2024.08.09 00:08:20.863526 [ 3389953 ] {} <Fatal> ClientBase: 4. src/thread/__timedwait.c:25: __timedwait_cp @ 0x000000001685d616
2024.08.09 00:08:20.864583 [ 3389953 ] {} <Fatal> ClientBase: 5. src/thread/pthread_cond_timedwait.c:100: pthread_cond_timedwait @ 0x000000001685cf33
2024.08.09 00:08:20.866043 [ 3389953 ] {} <Fatal> ClientBase: 6. ./build/./contrib/llvm-project/libcxx/src/condition_variable.cpp:47: std::condition_variable::wait(std::unique_lock<std::mutex>&) @ 0x00000000167b202f
2024.08.09 00:08:20.880054 [ 3389953 ] {} <Fatal> ClientBase: 7.0. inlined from ./contrib/llvm-project/libcxx/include/vector:553: std::vector<JobWithPriority, std::allocator<JobWithPriority>>::empty[abi:v15007]() const
2024.08.09 00:08:20.880077 [ 3389953 ] {} <Fatal> ClientBase: 7.1. inlined from ./contrib/boost/boost/heap/priority_queue.hpp:179: boost::heap::priority_queue<JobWithPriority, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::empty() const
2024.08.09 00:08:20.880088 [ 3389953 ] {} <Fatal> ClientBase: 7.2. inlined from ./build/./src/Common/ThreadPool.cpp:416: operator()
2024.08.09 00:08:20.880104 [ 3389953 ] {} <Fatal> ClientBase: 7.3. inlined from ./contrib/llvm-project/libcxx/include/__mutex_base:397: void std::condition_variable::wait<ThreadPoolImpl<std::thread>::worker(std::__list_iterator<std::thread, void*>)::'lambda'()>(std::unique_lock<std::mutex>&, ThreadPoolImpl<std::thread>::worker(std::__list_iterator<std::thread, void*>)::'lambda'())
2024.08.09 00:08:20.880120 [ 3389953 ] {} <Fatal> ClientBase: 7. ./build/./src/Common/ThreadPool.cpp:416: ThreadPoolImpl<std::thread>::worker(std::__list_iterator<std::thread, void*>) @ 0x000000000bd2b839
2024.08.09 00:08:20.900100 [ 3389953 ] {} <Fatal> ClientBase: 8.0. inlined from ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:302: std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>::reset[abi:v15007](std::__thread_struct*)
2024.08.09 00:08:20.900119 [ 3389953 ] {} <Fatal> ClientBase: 8.1. inlined from ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:259: ~unique_ptr
2024.08.09 00:08:20.900128 [ 3389953 ] {} <Fatal> ClientBase: 8.2. inlined from ./contrib/llvm-project/libcxx/include/tuple:265: ~__tuple_leaf
2024.08.09 00:08:20.900137 [ 3389953 ] {} <Fatal> ClientBase: 8.3. inlined from ./contrib/llvm-project/libcxx/include/tuple:538: ~tuple
2024.08.09 00:08:20.900157 [ 3389953 ] {} <Fatal> ClientBase: 8.4. inlined from ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:48: std::default_delete<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>>::operator()[abi:v15007](std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>*) const
2024.08.09 00:08:20.900183 [ 3389953 ] {} <Fatal> ClientBase: 8.5. inlined from ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:305: std::unique_ptr<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>, std::default_delete<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>>>::reset[abi:v15007](std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>*)
2024.08.09 00:08:20.900197 [ 3389953 ] {} <Fatal> ClientBase: 8.6. inlined from ./contrib/llvm-project/libcxx/include/__memory/unique_ptr.h:259: ~unique_ptr
2024.08.09 00:08:20.900208 [ 3389953 ] {} <Fatal> ClientBase: 8. ./contrib/llvm-project/libcxx/include/thread:297: void* std::__thread_proxy[abi:v15007]<std::tuple<std::unique_ptr<std::__thread_struct, std::default_delete<std::__thread_struct>>, void ThreadPoolImpl<std::thread>::scheduleImpl<void>(std::function<void ()>, Priority, std::optional<unsigned long>, bool)::'lambda0'()>>(void*) @ 0x000000000bd2fd6e
2024.08.09 00:08:20.901351 [ 3389953 ] {} <Fatal> ClientBase: 9. src/thread/pthread_create.c:207: start @ 0x000000001685db15
2024.08.09 00:08:20.902287 [ 3389953 ] {} <Fatal> ClientBase: 10. src/thread/x86_64/clone.s:23: ? @ 0x000000001685f9ad
...

ClickHouse/ClickHouse#67921

@alexey-milovidov alexey-milovidov self-assigned this Aug 10, 2024
@alexey-milovidov alexey-milovidov merged commit a76e977 into master Aug 10, 2024
@alexey-milovidov
Copy link
Member

Maybe it has a chance to be accepted by upstream?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants