Skip to content

[release/9.0-staging] [mono][interp] Minor SSA fixes #116428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2025

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented Jun 9, 2025

This PR is a backport of two low risk fixes for interpreter SSA, one observed on customer provided sample and another fix for issue observed from local testing from our test suites. In addition, this includes support for a configuration env var, to enable users to disable SSA optimizations if they run into additional issues.

More conservative approach to #116250

Customer Impact

  • Customer reported
  • Found internally

This is currently impacting users of Maui on iOS, resulting in application crash. Multiple users reported crashes in #115991

Regression

  • Yes
  • No

SSA optimization for interpreter was introduced in .NET9 so it is a regression from .NET8.

Testing

Tested on sample projects where the issues occurred. Normal CI testing plus CI testing with tiering disabled to ensure these fixes don't cause regressions.

Risk

Low. The fixes are very localized.

BrzVlad added 3 commits June 9, 2025 13:35
…during cprop (dotnet#116179)

The definition was not updated, leading to invalid optimizations later on.
… optimization (dotnet#116069)

For each instruction in a basic block we check for patterns. In a certain case, once we replaced the instruction with a new one, we were attempting to do a loop reiteration by setting `ins = ins->prev` so after the loop reincrements with `ins = ins->next` we check super instruction patterns again for the current instruction. This is broken if `ins` was the first instruction in a basic block, aka `ins->prev` is NULL. This used to be impossible before SSA optimizations, since super instruction pass was applying optimizations in a single basic block only.
@BrzVlad BrzVlad added this to the 9.0.x milestone Jun 9, 2025
@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 10:51
@BrzVlad BrzVlad requested a review from kotlarmilos as a code owner June 9, 2025 10:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Backports two localized SSA fixes for the interpreter and adds configurable opt-out via an environment variable.

  • Ensures SSA def-tracking is updated after clearing old instructions in constant propagation.
  • Refines super-instruction logic to re-evaluate opcodes after a merge step.
  • Introduces MONO_INTERPRETER_OPTIONS env var to override interpreter options at runtime.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/mono/mono/mini/interp/transform-opt.c Update SSA def tracking and adjust super-instruction retry logic
src/mono/mono/mini/interp/interp.c Parse and apply MONO_INTERPRETER_OPTIONS from environment
Comments suppressed due to low confidence (1)

src/mono/mono/mini/interp/interp.c:8985

  • [nitpick] No tests currently cover parsing and application of MONO_INTERPRETER_OPTIONS. Adding a test case that sets this env var and verifies options parsing would guard against regressions.
const char *env_opts = g_getenv ("MONO_INTERPRETER_OPTIONS");

@@ -3801,9 +3805,7 @@ interp_super_instructions (TransformData *td)
g_print ("superins: ");
interp_dump_ins (ins, td->data_items);
}
Copy link
Preview

Copilot AI Jun 9, 2025

Choose a reason for hiding this comment

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

The new goto retry_ins no longer adjusts ins (original code did ins = ins->prev) so the intended behavior of re-evaluating the previous instruction is lost. Consider restoring ins = ins->prev before retry or clarifying the control flow to avoid changing logic or introducing infinite loops.

Suggested change
}
}
ins = ins->prev; // Adjust to re-evaluate the previous instruction

Copilot uses AI. Check for mistakes.

@jozkee
Copy link
Member

jozkee commented Jun 9, 2025

@BrzVlad reminder that servicing code complete for 9.0.7 is today @ 3PM PST.

@BrzVlad BrzVlad added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jun 10, 2025
@leecow leecow modified the milestones: 9.0.x, 9.0.7 Jun 10, 2025
@jozkee
Copy link
Member

jozkee commented Jun 10, 2025

/ba-g all new test failures are WasmTestOn* timeouts, #116444, the one now showing due to space limitations I believe is Workloads-NoWebcil-ST-Wasm.Build.Tests.WasmTemplateTests, also timeout.

@jozkee jozkee merged commit 2ec664a into dotnet:release/9.0-staging Jun 10, 2025
79 of 86 checks passed
@Emanuele9xx
Copy link

When will be available the 9.0.7 that contains all of this?

@BrzVlad
Copy link
Member Author

BrzVlad commented Jun 13, 2025

@Emanuele9xx In about a month

@Emanuele9xx
Copy link

Please consider to release before July because this fix a regression that causes many crashes, I think is a big issue for many many companies...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants