https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124811

--- Comment #2 from Michael Lloyd <michael at micl dot dev> ---
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.

Reply via email to