Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Comments

Fix Issue 18068 - No file names and line numbers in stack trace - Again#2278

Merged
wilzbach merged 1 commit intodlang:stablefrom
JinShil:fix_18068_again
Aug 20, 2018
Merged

Fix Issue 18068 - No file names and line numbers in stack trace - Again#2278
wilzbach merged 1 commit intodlang:stablefrom
JinShil:fix_18068_again

Conversation

@JinShil
Copy link
Contributor

@JinShil JinShil commented Aug 17, 2018

No description provided.

@dlang-bot
Copy link
Contributor

dlang-bot commented Aug 17, 2018

Thanks for your pull request, @JinShil!

Bugzilla references

Auto-close Bugzilla Severity Description
18068 regression No file names and line numbers in stack trace

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "stable + druntime#2278"

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Aug 17, 2018
@jacob-carlborg
Copy link
Contributor

How many times do we need to fix this and how can we prevent it from breaking?

@JinShil
Copy link
Contributor Author

JinShil commented Aug 17, 2018

Well, our CIs don't suffer from the problem for some reason.

@jacob-carlborg
Copy link
Contributor

Well, our CIs don't suffer from the problem for some reason.

Is it dependent on the distro?

@nemanja-boric-sociomantic
Copy link
Contributor

Yeah, we're probably not on a rolling distro in CI: #2230 (comment)

This update on Arch broke it:

glibc 2.28-1
binutils 2.31.1-1
4.17.12-arch1-1-ARCH
dmd-2.081.1```

@wilzbach
Copy link
Contributor

Hmm I use Arch too (with glibc 2.28-4 now) and I don't experience any issues, so before we remove code that makes sense, can we ensure that this actually is still a reproducible issue?

@nemanja-boric-sociomantic @Boris-Barboris what do you to run into this issue?
Compiling this:

void main()
{
    throw new Exception("aa");
}
dmd -g foo.d && ./foo

works fine for me.

@Boris-Barboris
Copy link

Boris-Barboris commented Aug 20, 2018

@wilzbach

I'll use lxc arch container for demonstration (but i noticed the bug on my main non-containerized arch install):

  1. lxc launch images:archlinux dmdtest
  2. Attach to it: lxc exec dmdtest /bin/bash
  3. Update arch: pacman -Ss && pacman -Syu
  4. Install gcc and binutils: pacman -S binutils gcc
  5.    pacman -Q | grep glibc
       glibc 2.28-4
       pacman -Q | grep binuti
       binutils 2.31.1-3```
    
  6. Install dmd: curl https://dlang.org/install.sh | bash -s
  7. Activate it: . dlang/dmd-2.081.2/activate
  8. dmd --version ... DMD64 D Compiler v2.081.2
  9. echo 'void main() { throw new Exception("aa"); }' > foo.d
  10. dmd -g foo.d && ./foo
    object.Exception@foo.d(1): aa
    ----------------
    ??:? _Dmain [0x6f044673]

P.S. I can provide ssh access to the container if you need.
P.S.2 Sent you email with credentials.

@nemanja-boric-sociomantic
Copy link
Contributor

Same here, with nightly:

(dmd-master-2018-08-20)(dmd-2.081.2)burgos@labs-332:/home/burgos  $ pacman -Q | grep glibc
glibc 2.28-4
(dmd-2.081.2)burgos@labs-332:/home/burgos  $ source ~/dlang/dmd-master-2018-08-20/activate
(dmd-master-2018-08-20)(dmd-2.081.2)burgos@labs-332:/home/burgos  $ dmd --version
DMD64 D Compiler v2.081.2-master-8e52b4d
Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved written by Walter Bright
(dmd-master-2018-08-20)(dmd-2.081.2)burgos@labs-332:/home/burgos  $ echo 'void main() { throw new Exception("aa"); }' > foo.d
(dmd-master-2018-08-20)(dmd-2.081.2)burgos@labs-332:/home/burgos  $ dmd -g foo.d && ./foo
object.Exception@foo.d(1): aa
----------------
??:? _Dmain [0x66441663]

@wilzbach
Copy link
Contributor

wilzbach commented Aug 20, 2018

Okay I looked a bit more into this and the GNU's binutils linker (aka ld.bfd) seems to order the binary differently. With ld.bfd instead of ld.gold I can reproduce the error as well :/
For more details:

Details

Debug sections

On my machine:

 readelf --debug-dump=info foo
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x80 (32-bit)
   Version:       3
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : Digital Mars D v2.081.2
    <24>   DW_AT_language    : 19	(D)
    <25>   DW_AT_name        : foo.d
    <2b>   DW_AT_comp_dir    : /home/seb/dlang/dmd
    <3f>   DW_AT_low_pc      : 0x0
    <47>   DW_AT_entry_pc    : 0x0
    <4f>   DW_AT_ranges      : 0x0
    <53>   DW_AT_stmt_list   : 0x0
 <1><57>: Abbrev Number: 2 (DW_TAG_module)
    <58>   DW_AT_name        : foo
 <1><5c>: Abbrev Number: 3 (DW_TAG_subprogram)
    <5d>   DW_AT_name        : D main
    <64>   DW_AT_MIPS_linkage_name: _Dmain
    <6b>   DW_AT_decl_file   : 1
    <6c>   DW_AT_decl_line   : 1
    <6e>   DW_AT_external    : 1
    <6f>   DW_AT_low_pc      : 0x3294c
    <77>   DW_AT_high_pc     : 0x329aa
    <7f>   DW_AT_frame_base  : 0x0 (location list)
 <1><83>: Abbrev Number: 0

In Docker:

readelf --debug-dump=info foo
Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x6e (32-bit)
   Version:       3
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : Digital Mars D v2.081.2
    <24>   DW_AT_language    : 19	(D)
    <25>   DW_AT_name        : foo.d
    <2b>   DW_AT_comp_dir    : /
    <2d>   DW_AT_low_pc      : 0x0
    <35>   DW_AT_entry_pc    : 0x0
    <3d>   DW_AT_ranges      : 0x0
    <41>   DW_AT_stmt_list   : 0x0
 <1><45>: Abbrev Number: 2 (DW_TAG_module)
    <46>   DW_AT_name        : foo
 <1><4a>: Abbrev Number: 3 (DW_TAG_subprogram)
    <4b>   DW_AT_name        : D main
    <52>   DW_AT_MIPS_linkage_name: _Dmain
    <59>   DW_AT_decl_file   : 1
    <5a>   DW_AT_decl_line   : 1
    <5c>   DW_AT_external    : 1
    <5d>   DW_AT_low_pc      : 0x3361c
    <65>   DW_AT_high_pc     : 0x3367a
    <6d>   DW_AT_frame_base  : 0x0 (location list)
 <1><71>: Abbrev Number: 0

With this PR on Docker:

Contents of the .debug_info section:

  Compilation Unit @ offset 0x0:
   Length:        0x83 (32-bit)
   Version:       3
   Abbrev Offset: 0x0
   Pointer Size:  8
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : Digital Mars D v2.081.2-365-g565e27ec0-dirty
    <39>   DW_AT_language    : 19	(D)
    <3a>   DW_AT_name        : foo.d
    <40>   DW_AT_comp_dir    : /
    <42>   DW_AT_low_pc      : 0x0
    <4a>   DW_AT_entry_pc    : 0x0
    <52>   DW_AT_ranges      : 0x0
    <56>   DW_AT_stmt_list   : 0x0
 <1><5a>: Abbrev Number: 2 (DW_TAG_module)
    <5b>   DW_AT_name        : foo
 <1><5f>: Abbrev Number: 3 (DW_TAG_subprogram)
    <60>   DW_AT_name        : D main
    <67>   DW_AT_MIPS_linkage_name: _Dmain
    <6e>   DW_AT_decl_file   : 1
    <6f>   DW_AT_decl_line   : 1
    <71>   DW_AT_external    : 1
    <72>   DW_AT_low_pc      : 0x3360c
    <7a>   DW_AT_high_pc     : 0x3366a
    <82>   DW_AT_frame_base  : 0x0 (location list)
 <1><86>: Abbrev Number: 0

Code sections

objdump -h foo

foo:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .interp       0000001c  0000000000000270  0000000000000270  00000270  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.ABI-tag 00000020  000000000000028c  000000000000028c  0000028c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .note.gnu.build-id 00000024  00000000000002ac  00000000000002ac  000002ac  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .dynsym       0000a920  00000000000002d0  00000000000002d0  000002d0  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .dynstr       000179b3  000000000000abf0  000000000000abf0  0000abf0  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .gnu.hash     00003300  00000000000225a8  00000000000225a8  000225a8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .gnu.version  00000e18  00000000000258a8  00000000000258a8  000258a8  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .gnu.version_r 000000d0  00000000000266c0  00000000000266c0  000266c0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rela.dyn     0000b430  0000000000026790  0000000000026790  00026790  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .rela.plt     00000768  0000000000031bc0  0000000000031bc0  00031bc0  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 .init         0000001b  0000000000032328  0000000000032328  00032328  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 11 .plt          00000500  0000000000032350  0000000000032350  00032350  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 12 .text         0002c1c5  0000000000032850  0000000000032850  00032850  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 13 .fini         0000000d  000000000005ea18  000000000005ea18  0005ea18  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 14 .rodata       00002380  000000000005ea30  000000000005ea30  0005ea30  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 .gcc_except_table 000006ac  0000000000060db0  0000000000060db0  00060db0  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 16 .eh_frame     00009e04  0000000000061460  0000000000061460  00061460  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 .eh_frame_hdr 00002624  000000000006b264  000000000006b264  0006b264  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 18 .tdata        00000010  000000000006e8f0  000000000006e8f0  0006d8f0  2**4
                  CONTENTS, ALLOC, LOAD, DATA, THREAD_LOCAL
 19 .tcommon      00000000  000000000006e900  000000000006e900  0006d900  2**4
                  ALLOC, THREAD_LOCAL
 20 .tbss         00000148  000000000006e900  000000000006e900  0006d900  2**4
                  ALLOC, THREAD_LOCAL
 21 .fini_array   00000010  000000000006e900  000000000006e900  0006d900  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 22 .init_array   00000010  000000000006e910  000000000006e910  0006d910  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 23 .data.rel.ro  00000360  000000000006e920  000000000006e920  0006d920  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 24 .dynamic      00000240  000000000006ec80  000000000006ec80  0006dc80  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 25 .got          00000120  000000000006eec8  000000000006eec8  0006dec8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 26 .got.plt      00000290  000000000006efe8  000000000006efe8  0006dfe8  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 27 .data         0000a740  000000000006f280  000000000006f280  0006e280  2**6
                  CONTENTS, ALLOC, LOAD, DATA
 28 .tm_clone_table 00000000  00000000000799c0  00000000000799c0  000789c0  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 29 minfo         000000a0  00000000000799c0  00000000000799c0  000789c0  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 30 .bss          00000ac0  0000000000079a80  0000000000079a80  00078a60  2**6
                  ALLOC
 31 .comment      00000012  0000000000000000  0000000000000000  00078a60  2**0
                  CONTENTS, READONLY
 32 .note         00000000  0000000000000000  0000000000000000  00078a72  2**0
                  CONTENTS, READONLY
 33 .debug_str    00000000  0000000000000000  0000000000000000  00078a72  2**0
                  CONTENTS, READONLY, DEBUGGING
 34 .debug_ranges 00000020  0000000000000000  0000000000000000  00078a72  2**0
                  CONTENTS, READONLY, DEBUGGING
 35 .debug_loc    0000004c  0000000000000000  0000000000000000  00078a92  2**0
                  CONTENTS, READONLY, DEBUGGING
 36 .debug_line   00000074  0000000000000000  0000000000000000  00078ade  2**0
                  CONTENTS, READONLY, DEBUGGING
 37 .debug_abbrev 00000033  0000000000000000  0000000000000000  00078b52  2**0
                  CONTENTS, READONLY, DEBUGGING
 38 .debug_info   00000084  0000000000000000  0000000000000000  00078b85  2**0
                  CONTENTS, READONLY, DEBUGGING
 39 .debug_pubnames 0000001d  0000000000000000  0000000000000000  00078c09  2**0
                  CONTENTS, READONLY, DEBUGGING
 40 .debug_aranges 00000030  0000000000000000  0000000000000000  00078c26  2**0
                  CONTENTS, READONLY, DEBUGGING
 41 .note.gnu.gold-version 0000001c  0000000000000000  0000000000000000  00078c58  2**2
                  CONTENTS, READONLY
> objdump -h foo

foo:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .interp       0000001c  00000000000002e0  00000000000002e0  000002e0  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .note.ABI-tag 00000020  00000000000002fc  00000000000002fc  000002fc  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .note.gnu.build-id 00000024  000000000000031c  000000000000031c  0000031c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .gnu.hash     00003300  0000000000000340  0000000000000340  00000340  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .dynsym       0000a938  0000000000003640  0000000000003640  00003640  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .dynstr       00017970  000000000000df78  000000000000df78  0000df78  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .gnu.version  00000e1a  00000000000258e8  00000000000258e8  000258e8  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  7 .gnu.version_r 000000d0  0000000000026708  0000000000026708  00026708  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  8 .rela.dyn     0000b520  00000000000267d8  00000000000267d8  000267d8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .rela.plt     00000768  0000000000031cf8  0000000000031cf8  00031cf8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 10 .init         0000001b  0000000000033000  0000000000033000  00033000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 11 .plt          00000500  0000000000033020  0000000000033020  00033020  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 12 .text         0002c1c5  0000000000033520  0000000000033520  00033520  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 13 .fini         0000000d  000000000005f6e8  000000000005f6e8  0005f6e8  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 14 .rodata       00002380  0000000000060000  0000000000060000  00060000  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 15 .eh_frame_hdr 00002624  0000000000062380  0000000000062380  00062380  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 16 .eh_frame     000091a8  00000000000649a8  00000000000649a8  000649a8  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 17 .gcc_except_table 000006ac  000000000006db50  000000000006db50  0006db50  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
 18 .tdata        00000010  000000000006f8c0  000000000006f8c0  0006e8c0  2**4
                  CONTENTS, ALLOC, LOAD, DATA, THREAD_LOCAL
 19 .tbss         00000150  000000000006f8d0  000000000006f8d0  0006e8d0  2**4
                  ALLOC, THREAD_LOCAL
 20 .init_array   00000010  000000000006f8d0  000000000006f8d0  0006e8d0  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 21 .fini_array   00000010  000000000006f8e0  000000000006f8e0  0006e8e0  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 22 .data.rel.ro  00000360  000000000006f8f0  000000000006f8f0  0006e8f0  2**4
                  CONTENTS, ALLOC, LOAD, DATA
 23 .dynamic      00000240  000000000006fc50  000000000006fc50  0006ec50  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 24 .got          00000170  000000000006fe90  000000000006fe90  0006ee90  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 25 .got.plt      00000290  0000000000070000  0000000000070000  0006f000  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 26 .data         0000a740  00000000000702c0  00000000000702c0  0006f2c0  2**6
                  CONTENTS, ALLOC, LOAD, DATA
 27 minfo         000000a0  000000000007aa00  000000000007aa00  00079a00  2**3
                  CONTENTS, ALLOC, LOAD, DATA
 28 .bss          00000ac0  000000000007aac0  000000000007aac0  00079aa0  2**6
                  ALLOC
 29 .comment      00000011  0000000000000000  0000000000000000  00079aa0  2**0
                  CONTENTS, READONLY
 30 .debug_aranges 00000030  0000000000000000  0000000000000000  00079ab1  2**0
                  CONTENTS, READONLY, DEBUGGING
 31 .debug_pubnames 0000001d  0000000000000000  0000000000000000  00079ae1  2**0
                  CONTENTS, READONLY, DEBUGGING
 32 .debug_info   00000072  0000000000000000  0000000000000000  00079afe  2**0
                  CONTENTS, READONLY, DEBUGGING
 33 .debug_abbrev 00000033  0000000000000000  0000000000000000  00079b70  2**0
                  CONTENTS, READONLY, DEBUGGING
 34 .debug_line   0000009b  0000000000000000  0000000000000000  00079ba3  2**0
                  CONTENTS, READONLY, DEBUGGING
 35 .debug_loc    0000004c  0000000000000000  0000000000000000  00079c3e  2**0
                  CONTENTS, READONLY, DEBUGGING
 36 .debug_ranges 00000020  0000000000000000  0000000000000000  00079c8a  2**0
                  CONTENTS, READONLY, DEBUGGING

In fact when looking at it in gdb, the first header that gets iterated when linked with ld.gold has p_vaddr of 0

$4 = (const core.sys.linux.elf.Elf64_Phdr &) @0x5555555540b0: {
  p_type = 0x1, 
  p_flags = 0x5, 
  p_offset = 0x0, 
  p_vaddr = 0x0, 
  p_paddr = 0x0, 
  p_filesz = 0x7f9b8, 
  p_memsz = 0x7f9b8, 
  p_align = 0x1000
}

@wilzbach wilzbach changed the base branch from master to stable August 20, 2018 13:44
Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me now. I rebased to stable, s.t. we can get it in for 2.082.
In terms of reproducing this the best option would probably be to add a machine with a new glibc + kernel to the Buildkite tester ...

@wilzbach wilzbach merged commit 45f340f into dlang:stable Aug 20, 2018
@JinShil JinShil deleted the fix_18068_again branch August 20, 2018 15:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Bug Fix Include reference to corresponding bugzilla issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants