D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19473 - DMD Segfault on circular struct reference
Summary: DMD Segfault on circular struct reference
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-10 16:18 UTC by deadalnix
Modified: 2018-12-16 20:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description deadalnix 2018-12-10 16:18:04 UTC
DMD Segfault on the following sample code:

struct A {
	P p;

	struct UTpl() {
		union {
			P p;
		}
	}

	alias U() = UTpl!();
}

alias B = A.U!();

struct C {
	union D {
		B b;
	}
}

union P {
	C.D p;
}


I have not been able to reduce the sample case further and I'm not quite sure what's going on.
Comment 1 deadalnix 2018-12-10 17:01:36 UTC
Running on older version of DMD tells me it is a regression.

2.066.0 to 2.071.2: Failure with output: onlineapp.d(21): Error: union onlineapp.P no size yet for forward reference
Comment 2 Walter Bright 2018-12-12 11:39:46 UTC
There's certainly an unresolvable circular thing going on here.
Comment 3 Walter Bright 2018-12-12 23:26:12 UTC
It's an infinite loop trying to determine the sizes for:

    P => D => UTpl => P ...

resulting in a stack overflow.
Comment 4 Walter Bright 2018-12-12 23:58:29 UTC
https://github.com/dlang/dmd/pull/9072
Comment 5 github-bugzilla 2018-12-16 20:53:40 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/d2b6fc972aec7b5a518b437f4ec0f8e184d549be
fix Issue 19473 - DMD Segfault on circular struct reference

https://github.com/dlang/dmd/commit/5aa95b571b473666b9e68dd1cb07c8dd0b008925
Merge pull request #9072 from WalterBright/fix19473

fix Issue 19473 - DMD Segfault on circular struct reference