Skip to content

Restore stress guards on process-isolated IL tests - #131769

Merged
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:fix-131447-il-stress-guards
Aug 4, 2026
Merged

Restore stress guards on process-isolated IL tests#131769
EgorBo merged 1 commit into
dotnet:mainfrom
EgorBo:fix-131447-il-stress-guards

Conversation

@EgorBo

@EgorBo EgorBo commented Aug 3, 2026

Copy link
Copy Markdown
Member

Fixes #131447.

Root cause

Not a JIT bug. #126108 replaced the <JitOptimizationSensitive> and <GCStressIncompatible> MSBuild properties with [SkipOnCoreClr(...)] attributes on test entry points. That works for C# tests and for in-process IL tests, but silently drops the guard for IL tests that also set <RequiresProcessIsolation>:

Test kind What evaluates the skip Result
C#, any isolation GenerateStandaloneSimpleTestRunner compiles the check into __GeneratedMainWrapper.Main ✅ honored
IL, in-process merged runner reads the attribute from metadata via ExternallyReferencedTestMethodsVisitor ✅ honored
IL + process isolation merged runner emits an OutOfProcessTest that only calls RunOutOfProcessTest(...) on the generated run script, and ReferenceXUnitWrapperGenerator is gated on '$(Language)' == 'C#' so the IL assembly's hand-written .entrypoint never gets a wrapper either nothing reads the attribute

In that last case only the MSBuild property puts the guard into the generated .cmd/.sh.

arrres_il_r keeps its whole body in a single Main, so unoptimized codegen (tier-0, minopts, JIT stress) keeps the Test objects alive in untracked stack slots for the duration of Main. They are then never finalized and never resurrected, and the test throws. It fails on every default (tiered) run, which is why it lit up across outerloop, jitstress and pgo on all platforms at once.

Fix

Restore the MSBuild property on the two affected tests (option 1 from #126108 (comment)):

  • arrres_il_r.ilproj<JitOptimizationSensitive>
  • b143840.ilproj<GCStressIncompatible> (same bug, unguarded on gcstress legs; it kept <RequiresProcessIsolation> for <UnloadabilityIncompatible>)

The [SkipOnCoreClr] attributes are intentionally left in place, so the guard keeps working if either test ever stops requiring process isolation. Each project gets a comment explaining why the property cannot be dropped in favour of the attribute.

Fallout audit

I enumerated all 16 IL tests carrying [SkipOnCoreClr] and evaluated each owning project's effective RequiresProcessIsolation with msbuild -getProperty (so inherited Directory.Build.props/.targets values are accounted for). These two are the only process-isolated ones — the other 14 are in-process and unaffected.

I also confirmed empirically, rather than by inspection alone, that both of the "honored" rows above really do emit the guard, by disassembling the built assemblies:

  • Directed_3.dll (merged runner, in-process IL) contains IsJitStress / IsJitStressRegs / IsJitMinOpts / IsTailCallStress / IsTieredCompilation checks guarding the call to [AttributeConflict]P::Main().
  • ObjectStackAllocationTests.dll (process-isolated C#) contains the same checks inside __GeneratedMainWrapper.

No C# test is affected by this class of bug.

Validation

Built and ran the generated run scripts on windows-x64 checked:

arrres_il_r  default (tiered)     SKIP
             TieredCompilation=0  PASS  (Test passed., 100)
             TC=0 + JITMinOpts=1  SKIP
             TC=0 + JitStress=2   SKIP
b143840      default              PASS
             GCStress=0xC         SKIP

Before the change, arrres_il_r reproduced the exact CI signature under the default environment: unhandled System.Exception in GCTest_arrres_il.Test.Main, exit -532462766.

cc @jkoritzinsky @jakobbotsch @JulieLeeMSFT

Fixes dotnet#131447

PR dotnet#126108 replaced the `<JitOptimizationSensitive>` and `<GCStressIncompatible>`
MSBuild properties with `[SkipOnCoreClr(...)]` attributes on test entry points.
That works for C# tests and for in-process IL tests, but silently drops the guard
for IL tests that also set `<RequiresProcessIsolation>`:

- C#, any isolation: `GenerateStandaloneSimpleTestRunner` compiles the skip check
  into `__GeneratedMainWrapper.Main`, so the attribute is honored.
- IL, in-process: the merged runner reads the attribute from metadata via
  `ExternallyReferencedTestMethodsVisitor` and emits the skip, so it is honored.
- IL + process isolation: the merged runner emits an `OutOfProcessTest` whose body
  is just `RunOutOfProcessTest(...)` on the generated run script, and
  `ReferenceXUnitWrapperGenerator` is gated on `'$(Language)' == 'C#'`, so an IL
  assembly with a hand-written `.entrypoint` never gets a wrapper either. Nothing
  ever reads the attribute, and only the MSBuild property puts the guard into the
  generated .cmd/.sh.

Two tests hit that last case, and both are fixed here by restoring the property:

- `arrres_il_r` lost `<JitOptimizationSensitive>`. Its whole body is a single
  `Main`, so unoptimized codegen (tier-0, minopts, JIT stress) keeps the `Test`
  objects alive in untracked stack slots for the duration of `Main`. They are then
  never finalized and never resurrected, and the test throws. This is what dotnet#131447
  reports; it fails on every default (tiered) run, which is why it showed up across
  outerloop, jitstress and pgo on all platforms.

- `b143840` lost `<GCStressIncompatible>`, leaving it unguarded on gcstress legs.
  It kept `<RequiresProcessIsolation>` for `<UnloadabilityIncompatible>`.

Audited all 16 IL tests carrying `[SkipOnCoreClr]` by evaluating each project's
effective `RequiresProcessIsolation` with MSBuild; these two are the only
process-isolated ones. The `[SkipOnCoreClr]` attributes are left in place so the
guard keeps working if these tests ever stop requiring process isolation.

Verified locally on windows-x64 checked with the generated run scripts:

  arrres_il_r  default (tiered)     SKIP
               TieredCompilation=0  PASS (Test passed., 100)
               TC=0 + JITMinOpts=1  SKIP
               TC=0 + JitStress=2   SKIP
  b143840      default              PASS
               GCStress=0xC         SKIP

Before the change, `arrres_il_r` reproduced the exact CI failure signature
(unhandled `System.Exception` in `GCTest_arrres_il.Test.Main`, exit -532462766).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a984328a-8b6c-4221-b2c9-d668eae5b505
Copilot AI review requested due to automatic review settings August 3, 2026 20:35
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 3, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

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.

Pull request overview

Restores MSBuild-based stress guards for process-isolated IL tests by reintroducing the appropriate project properties (since [SkipOnCoreClr] on hand-written IL .entrypoint methods is not evaluated in the out-of-process runner path).

Changes:

  • Re-add <GCStressIncompatible>true</GCStressIncompatible> to b143840.ilproj, with rationale explaining why the MSBuild property is required for process-isolated IL tests.
  • Re-add <JitOptimizationSensitive>true</JitOptimizationSensitive> to arrres_il_r.ilproj, with rationale covering both the optimization sensitivity and the process-isolation runner behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/tests/JIT/Regression/CLR-x86-JIT/V1.1-M1-Beta1/b143840/b143840.ilproj Restores GCStressIncompatible MSBuild guard for a process-isolated IL test and documents why the attribute alone isn’t sufficient.
src/tests/JIT/Methodical/Arrays/misc/arrres_il_r.ilproj Restores JitOptimizationSensitive MSBuild guard for a process-isolated IL test and documents why it must remain.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@EgorBo
EgorBo merged commit 389be14 into dotnet:main Aug 4, 2026
84 of 86 checks passed
@EgorBo
EgorBo deleted the fix-131447-il-stress-guards branch August 4, 2026 01:15
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Aug 4, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure: JIT/Methodical/Arrays/misc/arrres_il_r/arrres_il_r.cmd

3 participants