Bug 6047 – Segfault when struct with three or more ulongs with a toString is passed to format with at least two substitution clauses with -m64.

Status
RESOLVED
Resolution
WORKSFORME
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2011-05-23T05:01:00Z
Last change time
2012-04-28T01:42:08Z
Keywords
wrong-code
Assigned to
nobody
Creator
b.helyer
Depends on
6983

Comments

Comment #0 by b.helyer — 2011-05-23T05:01:35Z
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.
Comment #1 by b.helyer — 2011-05-23T05:05:16Z
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.
Comment #2 by kennytm — 2011-05-23T05:57:50Z
(No-repro on Mac OS X.)
Comment #3 by b.helyer — 2011-05-23T06:31:32Z
I was mistaken -- it's only when building a 64 bit binary.
Comment #4 by bus_dbugzilla — 2011-11-19T20:59:15Z
Raising priority because this is a rather nasty bug to come up against.
Comment #5 by bus_dbugzilla — 2011-11-21T07:44:59Z
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, ""); }
Comment #6 by bus_dbugzilla — 2011-11-21T07:59:44Z
Issue 6576 may be related to this.
Comment #7 by bus_dbugzilla — 2011-11-21T08:46:34Z
I think the root cause of this might be issue 6983.
Comment #8 by bugzilla — 2012-04-28T01:42:08Z
I tried this for -m32 and -m64 on Linux, and the program completes without error on dmd 2.060 latest build.