Thread overview
[Issue 6047] New: Segfault when struct with three or more ulongs with a toString is passed to format with at least two substitution clauses.
May 23, 2011
Bernard Helyer
May 23, 2011
Bernard Helyer
May 23, 2011
kennytm@gmail.com
May 23, 2011
Bernard Helyer
[Issue 6047] Segfault when struct with three or more ulongs with a toString is passed to format with at least two substitution clauses with -m64.
Nov 20, 2011
Nick Sabalausky
Nov 21, 2011
Nick Sabalausky
Nov 21, 2011
Nick Sabalausky
Nov 21, 2011
Nick Sabalausky
Apr 28, 2012
Walter Bright
May 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047

           Summary: Segfault when struct with three or more ulongs with a
                    toString is passed to format with at least two
                    substitution clauses.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: blood.of.life@gmail.com


--- Comment #0 from Bernard Helyer <blood.of.life@gmail.com> 2011-05-23 05:01:35 PDT ---
import std.string;

struct A { ulong a, b, c; string toString() { return ""; } }

void main()
{
    A a;
    format("%s%s", a, "");
}



There has to be at least 24 bytes (or so) of declarations, so at least three ulongs. The toString has to be there. That second parameter to format has to be there.

Somewhere, there is stack corruption happening. This is preventing SDC's 64 bit build from working correctly (it crashes when it errors, as the Location struct is passed to format, manifesting this when its size_t decls are 64 bits wide).

This could be from DMD or Phobos. I'm not sure.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #1 from Bernard Helyer <blood.of.life@gmail.com> 2011-05-23 05:05:16 PDT ---
I didn't mention my specs. Linux (64 or 32 bit build and output), 2.053 (but
it's been there for months, _at least_, to my knowledge), Phenom II X4, Arch
Linux.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #2 from kennytm@gmail.com 2011-05-23 05:57:50 PDT ---
(No-repro on Mac OS X.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #3 from Bernard Helyer <blood.of.life@gmail.com> 2011-05-23 06:31:32 PDT ---
I was mistaken -- it's only when building a 64 bit binary.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047


Nick Sabalausky <cbkbbejeap@mailinator.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |critical


--- Comment #4 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-11-19 20:59:15 PST ---
Raising priority because this is a rather nasty bug to come up against.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #5 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-11-21 07:44:59 PST ---
The format string can be blank and this bug will still be triggered. So a slight reduction is:

import std.string;

struct A { ulong a, b, c; string toString() { return ""; } }

void main()
{
    A a;
    format("", a, "");
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #6 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-11-21 07:59:44 PST ---
Issue 6576 may be related to this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 21, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6047



--- Comment #7 from Nick Sabalausky <cbkbbejeap@mailinator.com> 2011-11-21 08:46:34 PST ---
I think the root cause of this might be issue 6983.

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WORKSFORME


--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2012-04-28 01:42:08 PDT ---
I tried this for -m32 and -m64 on Linux, and the program completes without error on dmd 2.060 latest build.

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