Bug 3884 – Segfault: defining a typedef with an invalid object.d
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86_64
OS
Linux
Creation time
2010-03-06T00:54:00Z
Last change time
2014-02-15T02:28:22Z
Keywords
ice-on-invalid-code, patch
Assigned to
nobody
Creator
matti.niemenmaa+dbugzilla
Comments
Comment #0 by matti.niemenmaa+dbugzilla — 2010-03-06T00:54:56Z
The following code causes DMD 1.056 to segfault:
typedef int X;
X[] a;
void f() { g(a); }
void g(T...)(T x) {}
Using int[] instead of X[] works.
However, interestingly enough, keeping the typedef but using an int[] also causes a segfault, even though the typedef is unused:
typedef int X;
int[] a;
void f() { g(a); }
void g(T...)(T x) {}
Comment #1 by clugdbug — 2010-03-10T23:58:17Z
I cannot reproduce the bug on either 1.055 or 1.057 Windows, nor on D2. Is there something missing from the test case?
Comment #2 by matti.niemenmaa+dbugzilla — 2010-03-11T02:34:40Z
Took me a while to reproduce it again myself. It's quite different from what I reported: I had an invalid object.d in the working directory, which triggers it. It seems the typedef alone is enough, the array and tuple business is unneeded:
$ cat arst.d
typedef int X;
$ dmd -c arst.d
[no errors]
$ touch object.d
$ dmd -c arst.d
E: Child terminated by signal ‘Segmentation fault’
Comment #3 by clugdbug — 2010-03-16T01:02:39Z
This is really obscure, but here's a patch:
typeinf.c, line 108:
Expression *Type::getTypeInfo(Scope *sc)
{
Expression *e;
Type *t;
+ if (!Type::typeinfo)
+ {
+ error(0, "TypeInfo not found. object.d may be incorrectly installed or corrupt");
+ return new ErrorExp();
+ }
//printf("Type::getTypeInfo() %p, %s\n", this, toChars());