-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libunwind gives incorrect line number #123
Comments
Of course, with gcc's unwind, the line number was correct |
Hi, thanks for the report. In general it's not entirely surprising that a line number could be off on -O2, however there does seem to be a small cpptrace bug here :) In this case gcc detects the UB in bad():
mov DWORD PTR ds:0, 0
ud2 If I try plugging this into my local test setup, modified to print object addresses instead of runtime addresses, I see the same behavior
(where Looking at an objectdump 0000000000008570 <_Z3badv>:
void bad() { // ------> this is line 73
8570: f3 0f 1e fa endbr64
*p = 10; // ----------> this is line 78
8574: c7 04 25 00 00 00 00 mov DWORD PTR ds:0x0,0x0
857b: 00 00 00 00
857f: 0f 0b ud2
8581: 66 66 2e 0f 1f 84 00 data16 cs nop WORD PTR [rax+rax*1+0x0]
8588: 00 00 00 00
858c: 0f 1f 40 00 nop DWORD PTR [rax+0x0] The address returned from libunwind would have corresponded to
The reason why is that when you As to why clang wouldn't print anything, that's weird but it could be a general dwarf symbol resolution issue I haven't encountered yet. Does it happen when a stack trace is generated outside a signal tracing setup? |
I think the core of that issue should now be fixed on When I tested again locally that frame was resolving to the vector construction which seems to be another edge case but this time in how the inlined subroutine is encoded in dwarf
|
I am able to reproduce clang not printing symbols as well, it may be due to
|
Thank you for your response. I have checked out the |
Thanks for your patience. What version of clang are you using? I thought I had been able to reproduce however I am no longer able to, using clang 18. |
I'm using clang 14 on Ubuntu 22. I also tried clang 17 on Ubuntu 22. Neither of them work. |
Thanks for the additional information. Unfortunately I have been able to reproduce on either ubuntu 22 or 24 with clang 14, 17, or 18 on debug or release. There is a quirk of optimization surrounding I'm going to go ahead and close this issue for now since the core issues have been solved, however I'm very interested in hunting down any clang issues. If there is any more info you can provide to help reproduce I would be grateful. My guess would be some discrepancy in how the build is being done affecting where debug symbols are being placed. |
I've released v0.6.0 which includes the fix for this |
Thanks! |
I have tried the signal_safe demo and enabled libunwind. However, the line information in the stack trace appears to be incorrect. Here is my test main program:
The stacktrace generated with libunwind is
Howerver, the expected result is
Any idea why? Is the problem with libunwind?
My compile command was
g++ -o test test.cc -g1 -O2 -lcpptrace -ldwarf -lz -lzstd -lunwind -llzma -w -std=c++17 -fpic
If I do
O0
then the information was correct. Also, if I used clang, I got nothingThe text was updated successfully, but these errors were encountered: