D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3884 - Segfault: defining a typedef with an invalid object.d
Summary: Segfault: defining a typedef with an invalid object.d
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86_64 Linux
: P3 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
 
Reported: 2010-03-06 00:54 UTC by Matti Niemenmaa
Modified: 2014-02-15 02:28 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Matti Niemenmaa 2010-03-06 00:54:56 UTC
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 Don 2010-03-10 23:58:17 UTC
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 Matti Niemenmaa 2010-03-11 02:34:40 UTC
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 Don 2010-03-16 01:02:39 UTC
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());
Comment 4 Walter Bright 2010-03-28 14:29:22 UTC
changeset 426
Comment 5 Don 2010-04-09 13:40:48 UTC
Fixed DMD1.058 and 2.043.