Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
February 16, 2011 [Issue 5595] New: Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5595 Summary: Compiler crash on heavy std.algorithm use Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: ice-on-valid-code Severity: regression Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dsimcha@yahoo.com --- Comment #0 from David Simcha <dsimcha@yahoo.com> 2011-02-16 07:39:21 PST --- The following code crashes the compiler on Windows using the latest beta of 2.052. It works on 2.051. import std.algorithm, std.math, std.stdio, std.conv; // std.datetime isn't used but needs to be imported to reproduce the bug. import std.datetime; void invert(double[][] mat) { foreach(i, row; mat) { double absMax = map!(abs)(row).front; } } void readExp() { auto handle = File("foo.txt"); auto lines = handle.byLine(); auto ls = lines.front().splitter('\t'); if(!ls.empty) { auto floats = map!(to!float)(ls).front; } } void main(string[] args) {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 16, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #1 from Don <clugdbug@yahoo.com.au> 2011-02-16 07:58:26 PST --- Confirmed. I'm on it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 16, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 --- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-02-16 08:28:43 PST --- The regression was caused by a Phobos change, which has triggered a compiler segfault in interpret.c. In attempting to instantiate map!(to), 'to' is a symbol with no identifier. (.ident is NULL). The segfault can be prevented in dsymbol.c, line 70, by checking for a null identifier. But without knowing why we're getting a null identifier, I can't recommend this as a valid patch. int Dsymbol::equals(Object *o) { Dsymbol *s; if (this == o) return TRUE; s = (Dsymbol *)(o); - if (s && ident->equals(s->ident)) + if (s && s->ident && ident->equals(s->ident)) return TRUE; return FALSE; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 16, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 --- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-02-16 11:51:32 PST --- Slightly reduced test case: ----- import std.algorithm; import std.datetime; import std.math; void foo(A)(A x) {} void readExp() { int xxx; double[] yyy; map!(abs)(yyy); map!(foo)(xxx); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 16, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 --- Comment #4 from Don <clugdbug@yahoo.com.au> 2011-02-16 13:12:13 PST --- Reduced test case shows it involves overload sets of templates. Segfaults as far back as 2.012. Definitely not a regression. ==== test1.d === void bar(D)(D x) {} ==== test2.d === void bar(N)(N x) {} ==== test0.d === import test1, test2; template map(fun...) { void map(R)(R r) {} } void foo(A)(A x) {} void baz() { int xxx; char yyy; map!(bar)(yyy); map!(foo)(xxx); } ------- dmd test0 <segfault> -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 16, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 --- Comment #5 from Don <clugdbug@yahoo.com.au> 2011-02-16 14:23:24 PST --- Another reduction, uses test1.d and test2.d from the previous comment. It's clear that IFTI is not required. The issue is instantiating a tuple with an overload set. If you change the baz(F...) to baz(F) you get: test0.d(7): Error: template instance baz!(__anonymous) does not match template declaration baz(F) which shows that the overload set really doesn't have an identifier. Also, you can replace the (F...) with (alias F), and still get the segfault. So it is not a problem with tuples; it's a problem with overload sets of templates. ===== import test1, test2; void foo(A)() {} template baz(F...) { enum int baz = 1; } static assert(baz!bar == baz!foo); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 17, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch --- Comment #6 from Don <clugdbug@yahoo.com.au> 2011-02-16 23:40:07 PST --- I think my initial patch was basically correct. Overload sets are not equal to other Objects. ---- int Dsymbol::equals(Object *o) { Dsymbol *s; if (this == o) return TRUE; s = (Dsymbol *)(o); - if (s && ident->equals(s->ident)) + // Overload sets don't have an ident + if (s && ident && s->ident && ident->equals(s->ident)) return TRUE; return FALSE; } The interesting thing, which I hadn't realized before, is that a template alias parameter can be an overload set. The question this raises is, are there other places in the code where it's assumed that every DSymbol has an ident? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 18, 2011 [Issue 5595] Compiler crash on heavy std.algorithm use | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5595 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |FIXED --- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2011-02-17 16:19:28 PST --- https://github.com/D-Programming-Language/dmd/commit/f8ed1b3a6d8f1391962111a6d06783cf09bfd90a -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation