Bug 11684 – SIGSEGV with ld.bfd version 2.22

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P5
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-04T12:20:00Z
Last change time
2014-02-15T07:44:10Z
Keywords
pull, wrong-code
Assigned to
code
Creator
timothee.cour2

Attachments

IDFilenameSummaryContent-TypeSize
1299dmd_test.zipobject file and binary of simple hello world that failsapplication/zip162023

Comments

Comment #0 by timothee.cour2 — 2013-12-04T12:20:54Z
when building from git head on ubuntu, I'm now getting SIGSEGV upon calling writeln("some_string); Previously it worked.
Comment #1 by hsteoh — 2013-12-05T11:45:57Z
Post self-contained test case, please. I can't reproduce your problem in my environment (just updated to git HEAD, Debian/unstable 64-bit).
Comment #2 by hsteoh — 2013-12-05T11:46:50Z
P.S. Here is the code I tested: ------ import std.stdio; void main() { writeln("Hello"); } ------ No segfaults happened.
Comment #3 by kozzi11 — 2013-12-05T12:14:19Z
(In reply to comment #2) > P.S. Here is the code I tested: > ------ > import std.stdio; > > void main() { > writeln("Hello"); > } > ------ > > No segfaults happened. same here, ArchLinux 64 with out segfaults
Comment #4 by timothee.cour2 — 2013-12-05T15:10:54Z
(In reply to comment #3) > (In reply to comment #2) > > P.S. Here is the code I tested: > > ------ > > import std.stdio; > > > > void main() { > > writeln("Hello"); > > } > > ------ > > > > No segfaults happened. > > same here, ArchLinux 64 with out segfaults At least another user reported the same problem (see email: dmd git head completely broken on ubuntu (but not osx)) It fails for me on both Ubuntu 12.04.1 LTS (64bit) and Ubuntu 12.04.3 LTS (64bit), and the other user reported same issue on Ubuntu 12.04.3 LTS, x86_64 to reproduce: just do a fresh git clone of dmd/druntime/phobos and build as usual, then run this program: import std.stdio; void main() { writeln("Hello"); } it segfaults. then git checkout 2.064 on dmd/druntime/phobos, clean/rebuild, it doesn't segfault. So it's something introduced since then.
Comment #5 by hsteoh — 2013-12-05T19:20:55Z
I'm afraid you'll have to git bisect to find out when this started happening. I've been compiling medium-sized projects with git HEAD and everything runs without any problems, so my environment isn't useful to track down this problem.
Comment #6 by maxim — 2013-12-05T22:27:10Z
It is obvious that it is either a user problem or bug which is revealed in specific circumstances. Please attach: 1) Fully working binary 2) Object file only This will help to detect root of the issue.
Comment #7 by timothee.cour2 — 2013-12-09T13:04:12Z
Created attachment 1299 object file and binary of simple hello world that fails object file and binary of simple hello world that fails
Comment #8 by hsteoh — 2013-12-09T16:20:41Z
Interesting. The segfault is caused by stdout being null. But std.stdio's static this() does initialize it correctly. So the static this() somehow isn't getting called by the druntime startup code??? What compile flags are you using, and what's the contents of dmd.conf?
Comment #9 by timothee.cour2 — 2013-12-09T16:36:23Z
(In reply to comment #8) > Interesting. The segfault is caused by stdout being null. But std.stdio's > static this() does initialize it correctly. So the static this() somehow isn't > getting called by the druntime startup code??? $cat ./dmd/src/dmd.conf [Environment] DFLAGS=-Ipath/to/phobos -Ipath/to/druntime/import -L-Lpath/to/phobos/generated/linux/release/default/ -L--export-dynamic -L-lrt > What compile flags are you using, and what's the contents of dmd.conf? #compile flags: $./dmd/src/dmd -g -ofmain main.d Other than that I'm building dmd/druntime/phobos as usual, no special options etc.
Comment #10 by code — 2013-12-22T01:01:37Z
Just ran into this while preparing the release on a Ubuntu 12.04 box. The .ctors .dtors sections of the object files are truncated, they are 4 byte each, but they should be 8 byte for the 64-bit pointer. This is not an ld.gold issue, still investigating.
Comment #11 by code — 2013-12-22T01:27:51Z
Seems like changing the relocation at this line fixes the problem. https://github.com/D-Programming-Language/dmd/blob/2a589a19cbd7e95880653043ebb556bf214b8340/src/backend/elfobj.c#L3436 `reltype = (config.flags3 & CFG3pic) ? R_X86_64_64 : R_X86_64_32;` always use R_X86_64_64 `reltype = R_X86_64_64;` I'll still have to see why this didn't fail on other platforms. Probably because the section itself is NPTRSIZE aligned?
Comment #12 by code — 2013-12-22T10:12:53Z
Comment #13 by code — 2013-12-22T11:26:45Z
Comment #14 by github-bugzilla — 2013-12-22T13:11:12Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/8dce20837d4ae909ac98bc21354a7ba2d86cf902 fix Issue 11684 - SIGSEGV with ld.bfd version 2.22 - Don't use zero extended relocations in data segment, because we need to write out the whole 8-byte address. - Data relocations don't depend on PIC. - This regression was introduced with 0cba87c6330cd7853139f51448c0f98372fb76d7. Before this commit the code still wrote out an 8-byte address, so the zero extension worked happened to work for <4GB binaries. https://github.com/D-Programming-Language/dmd/commit/e8d0efc8ea7c2fe35f859dd5dce486b5361ae1ed Merge pull request #3011 from MartinNowak/fix11684 [2.065,Reg] fix Issue 11684 - SIGSEGV with ld.bfd version 2.22
Comment #15 by github-bugzilla — 2013-12-22T13:25:19Z
Commit pushed to 2.065 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3f3a526c00cb6d41b92d2ca4bbf0d22f90a697f6 Merge pull request #3011 from MartinNowak/fix11684 [2.065,Reg] fix Issue 11684 - SIGSEGV with ld.bfd version 2.22
Comment #16 by github-bugzilla — 2013-12-22T13:29:20Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c1f3cc76d82eee65f403347852a03a6bd2c1b605 Merge pull request #3011 from MartinNowak/fix11684 [2.065,Reg] fix Issue 11684 - SIGSEGV with ld.bfd version 2.22
Comment #17 by timothee.cour2 — 2013-12-22T13:41:28Z
(In reply to comment #16) > Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd > > https://github.com/D-Programming-Language/dmd/commit/c1f3cc76d82eee65f403347852a03a6bd2c1b605 > Merge pull request #3011 from MartinNowak/fix11684 > > [2.065,Reg] fix Issue 11684 - SIGSEGV with ld.bfd version 2.22 how come this wasn't auto-detected by the auto tester? isn't ubuntu part of the machines being tested?
Comment #18 by code — 2013-12-22T15:07:02Z
> how come this wasn't auto-detected by the auto tester? isn't ubuntu part of the machines being tested? I don't know which distributions are running on the auto-tester. But even if we threw 10x more machines on the problem there will always remain some configurations that don't get tested. For such a prominent thing as Ubuntu 12.04 LTS, this shouldn't happen though.
Comment #19 by timothee.cour2 — 2013-12-22T16:36:21Z
I don't see much details on distributions used here: https://d.puremagic.com/test-results/hosts/
Comment #20 by github-bugzilla — 2014-01-15T09:44:19Z
Comment #21 by yebblies — 2014-02-15T07:44:10Z
*** Issue 11630 has been marked as a duplicate of this issue. ***