Skip to content
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

Dart generates broken debug information #47289

Closed
ueman opened this issue Sep 27, 2021 · 13 comments
Closed

Dart generates broken debug information #47289

ueman opened this issue Sep 27, 2021 · 13 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@ueman
Copy link

ueman commented Sep 27, 2021

This issue was originally reported in getsentry/sentry-dart#591

flutter build apk --split-per-abi --obfuscate --split-debug-info myfolder --release --verbose generates broken debug information since this commit 2362cd5 in Dart and since this commit flutter/flutter@f190bfb in Flutter.

I will let others reply to this but the current state of affairs is that what flutter generates is definitely a broken file. This is me summarzing what @relaxolotl found out:

The generated .dynamic section includes bad DT_HASH, DT_STRTAB and DT_SYMTAB records that point to virtual addresses which are not in a valid segment. Unfortunately our ELF library (goblin) treats these as fatal whereas some other tools can skip over this.

You can however see that llvm-readelf will also complain about this:

/usr/local/Cellar/llvm/12.0.1/bin/llvm-readelf: warning: 'app.android-arm(flutter2.5).symbols': unable to parse DT_HASH: virtual address is not in any segment: 0x17a420
/usr/local/Cellar/llvm/12.0.1/bin/llvm-readelf: warning: 'app.android-arm(flutter2.5).symbols': unable to parse DT_STRTAB: virtual address is not in any segment: 0x17a338
/usr/local/Cellar/llvm/12.0.1/bin/llvm-readelf: warning: 'app.android-arm(flutter2.5).symbols': unable to parse DT_SYMTAB: virtual address is not in any segment: 0x17a3c0

The commit that introduces the reordering is this one: dart-lang/sdk@2362cd5

Source: getsentry/sentry-dart#591 (comment)

Edit: Also see getsentry/sentry-dart#591 (comment) for even more information.

@mraleph mraleph assigned mraleph and sstrickl and unassigned mraleph Sep 27, 2021
@mraleph
Copy link
Member

mraleph commented Sep 27, 2021

@sstrickl could you take a look at this?

@mraleph mraleph added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Sep 27, 2021
@sstrickl
Copy link
Contributor

Looking at it now.

@sstrickl
Copy link
Contributor

So, looking at an example separately written debugging file:

$ llvm-readelf-11 -SldW /tmp/save-debug-info-flag-testULIWJG/debug.so |& tee output.txt
llvm-readelf-11: warning: '/tmp/save-debug-info-flag-testULIWJG/debug.so': Unable to parse DT_HASH: virtual address is not in any segment: 0x98408
llvm-readelf-11: warning: '/tmp/save-debug-info-flag-testULIWJG/debug.so': Unable to parse DT_STRTAB: virtual address is not in any segment: 0x982f0
llvm-readelf-11: warning: '/tmp/save-debug-info-flag-testULIWJG/debug.so': Unable to parse DT_SYMTAB: virtual address is not in any segment: 0x98378
There are 15 section headers, starting at offset 0xe9dc8:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .note.gnu.build-id NOTE           0000000000000190 000190 000020 00   A  0   0  4
  [ 2] .rodata           NOBITS          00000000000001b0 0001b0 000000 00   A  0   0 16
  [ 3] .dynstr           STRTAB          00000000000982f0 0001b0 000085 00   A  0   0  8
  [ 4] .dynsym           DYNSYM          0000000000098378 000238 000090 18   A  3   1  8
  [ 5] .hash             HASH            0000000000098408 0002c8 000038 04   A  4   0  8
  [ 6] .text             NOBITS          000000000009c000 004000 000000 00  AX  0   0 16
  [ 7] .bss              NOBITS          0000000000168000 004000 000000 00  WA  0   0  8
  [ 8] .dynamic          DYNAMIC         0000000000168018 004000 000060 10  WA  3   0  8
  [ 9] .shstrtab         STRTAB          0000000000000000 004060 000086 00      0   0  8
  [10] .debug_abbrev     PROGBITS        0000000000000000 0040e6 00003b 00      0   0  1
  [11] .debug_info       PROGBITS        0000000000000000 004121 03d1a2 00      0   0  1
  [12] .debug_line       PROGBITS        0000000000000000 0412c3 05ea0e 00      0   0  1
  [13] .strtab           STRTAB          0000000000000000 09fcd8 0342b0 00      0   0  8
  [14] .symtab           SYMTAB          0000000000000000 0d3f88 015e40 18     13 3731  8
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  l (large), p (processor specific)

Elf file type is DYN (Shared object file)
Entry point 0x0
There are 6 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x000150 0x000150 R   0x8
  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x000300 0x098440 R   0x4000
  LOAD           0x004000 0x000000000009c000 0x000000000009c000 0x000000 0x0cb6c0 R E 0x4000
  LOAD           0x004000 0x0000000000168000 0x0000000000168000 0x000060 0x000078 RW  0x4000
  NOTE           0x000190 0x0000000000000190 0x0000000000000190 0x000020 0x000020 R   0x4
  DYNAMIC        0x004000 0x0000000000168018 0x0000000000168018 0x000060 0x000060 RW  0x8

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .note.gnu.build-id .rodata .dynstr .dynsym .hash 
   02     .text 
   03     .bss .dynamic 
   04     .note.gnu.build-id 
   05     .dynamic 
   None   .shstrtab .debug_abbrev .debug_info .debug_line .strtab .symtab 
Dynamic section at offset 0x4000 contains 6 entries:
  Tag                Type     Name/Value
  0x0000000000000004 (HASH)   0x98408
  0x0000000000000005 (STRTAB) 0x982f0
  0x000000000000000a (STRSZ)  133 (bytes)
  0x0000000000000006 (SYMTAB) 0x98378
  0x000000000000000b (SYMENT) 24 (bytes)
  0x0000000000000000 (NULL)   0x0

While it looks like there's a segment with those addresses in there, the segment starts with the NOBITS .rodata section, and so the later non-NOBITS sections in the segment have addresses which don't correspond to the loaded file contents for the segment. Will have a CL fixing this shortly.

@sstrickl
Copy link
Contributor

Fix is up for review in CL 214800.

@ueman
Copy link
Author

ueman commented Sep 28, 2021

Does this qualify for a hotfix release?

@mraleph
Copy link
Member

mraleph commented Sep 28, 2021

@ueman yes, we will request a cherry-pick

@dnfield
Copy link
Contributor

dnfield commented Sep 28, 2021

/cc @devoncarew

@devoncarew
Copy link
Member

If this has high impact - something we want to try and cherry pick sooner rather than later - we'll want a cp request for this asap (see the issue template at the bottom of https://github.com/dart-lang/sdk/wiki/Cherry-picks-to-a-release-channel).

@devoncarew
Copy link
Member

@athomas - no cherry pick for this as yet but FYI.

@sstrickl
Copy link
Contributor

Request is up: #47316

copybara-service bot pushed a commit that referenced this issue Sep 29, 2021
This ensures that the relocated addresses of sections with file contents
are contained in the loaded segment.

Fixes #47289

TEST=vm/dart{,_2}/use_save_debugging_info_flag

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try
Change-Id: I6f7f94900ab1f9f0cb5ead4b0dd63bd2402e5a19
Fixed: 47289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214800
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
@davidmartos96
Copy link
Contributor

@ueman yes, we will request a cherry-pick

@mraleph Does that apply to the Flutter SDK as well? I believe there is no issue tracking it in the Flutter repo.

@mraleph
Copy link
Member

mraleph commented Sep 29, 2021

@davidmartos96 yes, Flutter and Dart release processes are aligned

@marandaneto
Copy link

thanks for fixing you all, I confirm it's working (Flutter 2.5.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants