www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11684] New: SIGSEGV, std.stdio.__T7writelnTAyaZ.writeln() at std/stdio.d:1906

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684

           Summary: SIGSEGV, std.stdio.__T7writelnTAyaZ.writeln()  at
                    std/stdio.d:1906
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: timothee.cour2 gmail.com


--- Comment #0 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-04
12:20:54 PST ---
when building from git head on ubuntu, I'm now getting SIGSEGV upon calling
writeln("some_string);
Previously it worked.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 04 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx


--- Comment #1 from hsteoh quickfur.ath.cx 2013-12-05 11:45:57 PST ---
Post self-contained test case, please. I can't reproduce your problem in my
environment (just updated to git HEAD, Debian/unstable 64-bit).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #2 from hsteoh quickfur.ath.cx 2013-12-05 11:46:50 PST ---
P.S. Here is the code I tested:
------
import std.stdio;

void main() {
        writeln("Hello");
}
------

No segfaults happened.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Daniel Kozak <kozzi11 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kozzi11 gmail.com


--- Comment #3 from Daniel Kozak <kozzi11 gmail.com> 2013-12-05 12:14:19 PST ---
(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 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Timothee Cour <timothee.cour2 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timothee.cour2 gmail.com


--- Comment #4 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-05
15:10:54 PST ---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #5 from hsteoh quickfur.ath.cx 2013-12-05 19:20:55 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P4
                 CC|                            |code dawg.eu


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru


--- Comment #6 from Maxim Fomin <maxim maxim-fomin.ru> 2013-12-05 22:27:10 PST
---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 05 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #7 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-09
13:04:12 PST ---
Created an attachment (id=1299)
object file and binary of simple hello world that fails

object file and binary of simple hello world that fails

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #8 from hsteoh quickfur.ath.cx 2013-12-09 16:20:41 PST ---
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?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #9 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-09
16:36:23 PST ---
(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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 09 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P4                          |P5
         AssignedTo|nobody puremagic.com        |code dawg.eu


--- Comment #10 from Martin Nowak <code dawg.eu> 2013-12-22 01:01:37 PST ---
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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #11 from Martin Nowak <code dawg.eu> 2013-12-22 01:27:51 PST ---
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?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #12 from Martin Nowak <code dawg.eu> 2013-12-22 10:12:53 PST ---
This was introduced with
https://github.com/D-Programming-Language/dmd/commit/0cba87c6330cd7853139f51448c0f98372fb76d7.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, wrong-code
            Summary|SIGSEGV,                    |SIGSEGV with ld.bfd version
                   |std.stdio.__T7writelnTAyaZ. |2.22
                   |writeln()  at               |
                   |std/stdio.d:1906            |


--- Comment #13 from Martin Nowak <code dawg.eu> 2013-12-22 11:26:45 PST ---
https://github.com/D-Programming-Language/dmd/pull/3011

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #14 from github-bugzilla puremagic.com 2013-12-22 13:11:12 PST ---
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

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #15 from github-bugzilla puremagic.com 2013-12-22 13:25:19 PST ---
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

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #16 from github-bugzilla puremagic.com 2013-12-22 13:29:20 PST ---
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

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #17 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-22
13:41:28 PST ---
(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? -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #18 from Martin Nowak <code dawg.eu> 2013-12-22 15:07:02 PST ---
 how come this wasn't auto-detected by the auto tester? isn't ubuntu part of the

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. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #19 from Timothee Cour <timothee.cour2 gmail.com> 2013-12-22
16:36:21 PST ---
I don't see much details on distributions used here:
https://d.puremagic.com/test-results/hosts/

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684



--- Comment #20 from github-bugzilla puremagic.com 2014-01-15 09:44:19 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3f3a526c00cb6d41b92d2ca4bbf0d22f90a697f6
Merge pull request #3011 from MartinNowak/fix11684

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 15 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11684


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr puremagic.com


--- Comment #21 from yebblies <yebblies gmail.com> 2014-02-16 02:44:10 EST ---
*** Issue 11630 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 15 2014