Skip to content

Fix ICE/AV on string mixin of version=/debug= statements - #23465

Open
AMDphreak wants to merge 1 commit into
dlang:masterfrom
dlang-supplemental:fix/mixin-null-statement-crash
Open

Fix ICE/AV on string mixin of version=/debug= statements#23465
AMDphreak wants to merge 1 commit into
dlang:masterfrom
dlang-supplemental:fix/mixin-null-statement-crash

Conversation

@AMDphreak

Copy link
Copy Markdown

Summary

  • Fix ACCESS_VIOLATION / ICE when a string mixin contains statement-level version = / debug = (and similar parse paths that returned a null Statement).
  • parseStatement now returns ErrorStatement instead of null; mixin semantic null-guards the supplemental location.
  • Add fail_compilation/mixin_version_debug_assign.d.

Fixes #23464

Test plan

  • Reproduced crash on DMD v2.112.0 with mixin("version = foo;") / mixin("debug = 1;") (exit -1073741819 / 0xC0000005)
  • Built local dmd; same cases now exit 1 with normal diagnostics
  • CI fail_compilation test mixin_version_debug_assign.d

parseStatement returned null for those paths; mixin semantic then
dereferenced s.loc in errorSupplemental. Return ErrorStatement instead
and guard the supplemental location.

Fixes dlang#23464

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread compiler/src/dmd/parse.d
s = new AST.IfStatement(loc, param, condition, ifbody, elsebody, token.loc);
else
s = null; // don't propagate parsing errors
s = new AST.ErrorStatement; // don't propagate parsing errors as null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to me that these assignments are redundant with the fixed null checking in statementsem.d

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also please use ErrorStatement.get() (requires a rebase)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants