DMD hard-crashes with an access violation (0xC0000005 on Windows) when a string mixin contains a statement-level version = ident; or debug = …; declaration.
DMD version
DMD64 D Compiler v2.112.0
Also reproduced on current master (built locally as v2.113.0-beta.1 before the fix).
Steps to reproduce
void main()
{
mixin("version = foo;");
}
or:
void other()
{
mixin("debug = 1;");
}
Expected Behavior
A normal compile error (e.g. version / debug declaration must be at module level, or identifier expected), then non-zero exit without crashing.
Actual Behavior
Process terminates with ACCESS_VIOLATION (0xC0000005, exit code -1073741819 on Windows).
On Windows this shows up in Reliability Monitor / WER as repeated dmd.exe AppCrash entries.
Root cause
Parser.parseStatement handles version = / debug = as statements by emitting an error and returning null (same for some failed if parses that used s = null).
- String-mixin statement semantic then does:
if (!s || global.errors != errors)
{
errorSupplemental(s.loc, "while parsing string mixin statement");
...
}
When !s is true, s.loc is still evaluated → null dereference / AV.
Additional notes
- Searched existing
dlang/dmd issues for this mixin/version=/debug= crash pattern; did not find a prior report.
- A fix PR will follow shortly.
DMD hard-crashes with an access violation (
0xC0000005on Windows) when a string mixin contains a statement-levelversion = ident;ordebug = …;declaration.DMD version
Also reproduced on current master (built locally as
v2.113.0-beta.1before the fix).Steps to reproduce
or:
Expected Behavior
A normal compile error (e.g.
version/debugdeclaration must be at module level, or identifier expected), then non-zero exit without crashing.Actual Behavior
Process terminates with
ACCESS_VIOLATION(0xC0000005, exit code-1073741819on Windows).On Windows this shows up in Reliability Monitor / WER as repeated
dmd.exeAppCrash entries.Root cause
Parser.parseStatementhandlesversion =/debug =as statements by emitting an error and returningnull(same for some failedifparses that useds = null).When
!sis true,s.locis still evaluated → null dereference / AV.Additional notes
dlang/dmdissues for this mixin/version=/debug=crash pattern; did not find a prior report.