www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19653] New: Memory addresses in stacktraces for x86-64 ELFs

https://issues.dlang.org/show_bug.cgi?id=19653

          Issue ID: 19653
           Summary: Memory addresses in stacktraces for x86-64 ELFs are
                    only 4 bytes long and don't fall on instruction
                    boundary
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johannes.riecken gmail.com

I compile the file stacktrace.d: void main(){assert(false);} with ASLR turned
off and when running I get:

core.exception.AssertError stacktrace.d(2): Assertion failure
----------------
??:? _d_assertp [0x55586ed8]
??:? _Dmain [0x55586e20]



objdump -t stacktrace|grep _Dmain gives

0000000000032e0c  w    F .text 0000000000000019              _Dmain

And if I run gdb -q -nx -ex start -ex 'disas /rs _Dmain' -ex q stacktrace:

...
Dump of assembler code for function _Dmain:
   0x0000555555586e0c <+0>: 55  push   %rbp
   0x0000555555586e0d <+1>: 48 8b ec    mov    %rsp,%rbp
=> 0x0000555555586e10 <+4>: be 02 00 00 00  mov    $0x2,%esi
   0x0000555555586e15 <+9>: 48 8d 3d 44 c0 02 00    lea    0x2c044(%rip),%rdi  
     # 0x5555555b2e60 <_TMP0>
   0x0000555555586e1c <+16>:    e8 47 00 00 00  callq  0x555555586e68
<_d_assertp>
   0x0000555555586e21 <+21>:    31 c0   xor    %eax,%eax
   0x0000555555586e23 <+23>:    5d  pop    %rbp
   0x0000555555586e24 <+24>:    c3  retq   

So even if the first two 0x55 bytes were just truncated off, 0x...86e20 given
in the stack trace doesn't match the start of an instruction.

--
Feb 06