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



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



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




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




 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



15:10:54 PST ---


 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




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



---
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




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




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




16:36:23 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???
$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



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




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




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            |



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




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


[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




Commit pushed to 2.065 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3f3a526c00cb6d41b92d2ca4bbf0d22f90a697f6


[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




Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c1f3cc76d82eee65f403347852a03a6bd2c1b605


[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




13:41:28 PST ---

 Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd
 
 https://github.com/D-Programming-Language/dmd/commit/c1f3cc76d82eee65f403347852a03a6bd2c1b605

 
 [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




 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. -- 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




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




Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3f3a526c00cb6d41b92d2ca4bbf0d22f90a697f6


-- 
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



*** 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