Thread overview
[Issue 7234] New: Segmentation fault when using stdio
Jan 05, 2012
Robert Clipsham
Jan 26, 2012
Don
Jan 29, 2012
Walter Bright
Jan 29, 2012
Walter Bright
January 05, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7234

           Summary: Segmentation fault when using stdio
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: robert@octarineparrot.com


--- Comment #0 from Robert Clipsham <robert@octarineparrot.com> 2012-01-05 19:46:11 GMT ---
The following test case is invalid code, but it is reproducible using valid code (DustMite caused some issues here while narrowing down phobos). It segfaults with dmd 2.057 on both Ubuntu 32 and OS X 64. I've included a comment for how to get a valid code test case, it depends on phobos though!
----
template isInputRange(R) {
    enum bool isInputRange = is(typeof({ R r; if (r.empty) {} }));
}

void formattedWrite(Writer, Char, A...)(Writer w, in Char, A args) {
    foreach (i, arg; args)
        i= &formatGeneric!(Writer, typeof(arg), Char);
}

struct FormatSpec(Char) {}

void formatValue(Writer, T, Char)(Writer w, T val, ref FormatSpec!Char f) if
(!isInputRange!T) {
}

private void formatGeneric(Writer, D, Char)(Writer w, const(void)* arg, ref
FormatSpec!Char f) {
    formatValue(w, *cast(D*) arg, f);
}
struct File {
    void writefln(S...)(S args) {
        auto w = LockingTextWriter();
        formattedWrite(w, args);
    }

    struct LockingTextWriter {}
}

File stdout;

// You can replace the above with import std.stdio; and
// give the opDispatch below a valid signature to gain a
// valid code test case, it's rather large though!
struct Contract {
    void opDispatch()(){}
}
Contract*mOptional;
void populate()
{
    stdout.writefln("opt   : %s", mOptional);
}
----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7234


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-01-26 00:15:08 PST ---
This seems to be the same as bug 7231.
It reduces to:

struct Bug7324 {
  void opDispatch()(){}
}

void func7234()
{
   Bug7234 r;
   if (r.xxx) {};
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7234


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2012-01-28 20:48:41 PST ---
(In reply to comment #1)
> It reduces to:

That doesn't seg fault, but the original does.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7234



--- Comment #3 from github-bugzilla@puremagic.com 2012-01-28 23:22:31 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9926cfdf09c9ecf28a102183562996dea6217051 fix Issue 7234 - Segmentation fault when using stdio

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7234


Walter Bright <bugzilla@digitalmars.com> changed:

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


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