Skip to content

ICE/AV: string mixin of version = / debug = statement null-derefs in errorSupplemental #23464

Description

@AMDphreak

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;");
}
dmd -c -o- crash.d

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

  1. Parser.parseStatement handles version = / debug = as statements by emitting an error and returning null (same for some failed if parses that used s = null).
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions