Binaries linked with mold-2.30.0 randomly either work or crash in `_dl_relocate_object`
mhx opened this issue · 4 comments
mhx commented
After upgrading mold from 2.4.0 to 2.30.0, some binaries in my project would crash immediately when being run. Today, a user of the project also reported this.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7fd9f46 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
(gdb) bt
#0 0x00007ffff7fd9f46 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
#1 0x00007ffff7fe8b71 in dl_main () from /lib64/ld-linux-x86-64.so.2
#2 0x00007ffff7fe535f in _dl_sysdep_start () from /lib64/ld-linux-x86-64.so.2
#3 0x00007ffff7fe6a8d in _dl_start () from /lib64/ld-linux-x86-64.so.2
#4 0x00007ffff7fe5938 in _start () from /lib64/ld-linux-x86-64.so.2
#5 0x0000000000000001 in ?? ()
#6 0x00007fffffffdd3c in ?? ()
#7 0x0000000000000000 in ?? ()
I've done a bit of bisecting. The issue was introduced with 8090737:
commit 8090737d564e2ed5b85f14ca6f29041bfe699744
Author: Rui Ueyama <ruiu@cs.stanford.edu>
Date: Wed Feb 21 18:35:06 2024 +0900
Merge sections with different flags into a single section
Previously, mold didn't merge sections with the same name but different
section flags into a single section. This behavior is different from other
linkers and caused a compatibility issue.
Now, mold merges input sections by their names and types.
Fixes https://github.com/rui314/mold/issues/1196
And it looks like it has been fixed with 6463a7c:
commit 6463a7c48ab3d355be6a99e4f7e177bf959da398
Author: Rui Ueyama <ruiu@cs.stanford.edu>
Date: Thu Apr 18 20:20:09 2024 +0900
Fix non-deterministic behavior
So unfortunately, both 2.30.0 and 2.4.1 are affected by this problem.
rui314 commented
I'm preparing a new release, so please wait for it.
rui314 commented
As an issue, it's already been resolved at git head, so let me close it.
mhx commented
Thanks! I wasn't sure if you were aware that this could cause segfaulting binaries as the commit message for the fix just mentioned "non-deterministic behavior", so I thought I'd document it.
rui314 commented
Good point, I'll note it in the release notes.