[Bug debug/124811] Non-deterministic DWARF debug info (.debug_info, .debug_loclists) when using precompiled headers

2026-04-08 Thread michael at micl dot dev via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124811

--- Comment #3 from Michael Lloyd  ---
Created attachment 64173
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64173&action=edit
fixes the .debug_line_str non-determinism by sorting entries before output

The attached patch fixes the .debug_line_str non-determinism by sorting
entries before output:

  Before patch (setarch -R, -j8): 101/475 .o files differ
  After patch  (setarch -R, -j8):   0/475 .o files differ

This is just a demonstration/fix that probably doesn't address the 
core issue, but it should give someone with more knowledge a lead 
as to why PCH is non-deterministic even without ASLR.

[Bug debug/124811] Non-deterministic DWARF debug info (.debug_info, .debug_loclists) when using precompiled headers

2026-04-08 Thread michael at micl dot dev via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124811

--- Comment #4 from Michael Lloyd  ---
I have attached a patch which may give someone with more knowledge a lead.

[Bug debug/124811] Non-deterministic DWARF debug info (.debug_info, .debug_loclists) when using precompiled headers

2026-04-08 Thread michael at micl dot dev via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124811

--- Comment #2 from Michael Lloyd  ---
I tested with setarch -R (ADDR_NO_RANDOMIZE) and it helps but the issue
persists.

Building quickshell 0.2.1 (as before) with GCC 15.2.0-15, x86_64-linux-gnu,
kernel 6.19.8:

  Normal (ASLR enabled): 475/475 .o files diff, 6/6 .gch files diff
  setarch x86_64 -R: 475/475 .o files diff, 6/6 .gch files diff

However, disabling ASLR does dramatically reduce the magnitude of the
differences. Total differing bytes across all .o files:

  ASLR on:3,219,315 bytes diff
  ASLR off:   9,746 bytes diff

The .gch files show the same pattern. For the largest PCH (337 MB):

  ASLR on:   96,047,756 bytes diff
  ASLR off:   9,869 bytes diff

So, ASLR is responsible for most of the byte differences but disabling
it does not eliminate the non-determinism.

The remaining non-determinism breaks down as:

  With ASLR:154/475 .o files still have real diffs
  Without ASLR: 101/475 .o files still have real diffs

Of those 101 files in the no-ASLR case:

* 84 files differ in .debug_line_str (and sometimes .rela.debug_info)
* 17 files differ by only 3 bytes in .rodata (Qt rcc resource hash, 
  likely not a GCC issue)

The .debug_line_str differences are string ordering non-determinism.
The same set of strings (directory paths, filenames) appear in both
builds, but in different order. For example, in common.cpp.o:

  Build A: .../build_dir\0.../src/core/common.cpp\0
  Build B: .../src/core/common.cpp\0.../build_dir\0

When sorted the string tables are identical. 

There appears to be two distinct issues: 

1. ASLR leaking into .gch memory dumps (known from mentioned bugs)
2. Non-deterministic ordering of strings in .debug_line_str, which
   I would assume is related to GCC's PCH/debug-info handling.

[Bug debug/124811] Non-deterministic DWARF debug info (.debug_info, .debug_loclists) when using precompiled headers

2026-04-07 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124811

--- Comment #1 from Richard Biener  ---
Does building [the PCH] with address-space randomization disabled help?
(setarch -R)