Bug 22905 – gdb backtrace contains wrong location

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-03-20T10:33:09Z
Last change time
2023-12-28T21:20:13Z
Keywords
DebugInfo, pull
Assigned to
No Owner
Creator
Tim

Comments

Comment #0 by tim.dlang — 2022-03-20T10:33:09Z
The following example produces a wrong backtrace in gdb: //////////////////// mod_a.d ///////////////////// import mod_b; void main() { funcB(); } //////////////////// mod_b.d ///////////////////// import mod_c; void funcB() { funcC(0); } //////////////////// mod_c.d ///////////////////// void funcC(T)(T param, void delegate() dg = null) { asm { hlt; } } ////////////////////////////////////////////////// The example can be compiled with: dmd -g mod_a.d mod_b.d mod_c.d Running it with gdb allows to show a backtrace for the hlt-instruction: gdb --batch -ex run -ex bt ./mod_a [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. mod_c.funcC!(int).funcC(int, void() delegate) (dg=..., param=0) at ./mod_c.d:5 5 hlt; #0 mod_c.funcC!(int).funcC(int, void() delegate) (dg=..., param=0) at ./mod_c.d:5 #1 0x000055555559772c in mod_b.funcB() () at ./mod_c.d:1 #2 0x00005555555976e5 in D main () at ./mod_a.d:4 The backtrace contains the wrong location ./mod_c.d:1 for function funcB. Correct would be ./mod_b.d:4.
Comment #1 by dlang-bot — 2023-12-28T18:36:25Z
@tim-dlang created dlang/dmd pull request #15961 "Fix issue 22905 - gdb backtrace contains wrong location" fixing this issue: - Fix issue 22905 - gdb backtrace contains wrong location The default argument for function funcC in the example is wrapped in an implicit cast expression. The location for this expression was not changed to the call site, because the visit function returned earlier for unary expressions. Now the location is changed for every type of expression. https://github.com/dlang/dmd/pull/15961
Comment #2 by dlang-bot — 2023-12-28T21:20:13Z
dlang/dmd pull request #15961 "Fix issue 22905 - gdb backtrace contains wrong location" was merged into master: - d7cbcbecdfde13bc5afbb21dc15095b828da815c by Tim Schendekehl: Fix issue 22905 - gdb backtrace contains wrong location The default argument for function funcC in the example is wrapped in an implicit cast expression. The location for this expression was not changed to the call site, because the visit function returned earlier for unary expressions. Now the location is changed for every type of expression. https://github.com/dlang/dmd/pull/15961