Skip to content

Remove undefined-behavior UnsafeTests.DangerousAs to stabilize jitstress leg - #129793

Merged
jkotas merged 3 commits into
mainfrom
copilot/fix-unsafe-tests-dangerous-as
Jun 26, 2026
Merged

Remove undefined-behavior UnsafeTests.DangerousAs to stabilize jitstress leg#129793
jkotas merged 3 commits into
mainfrom
copilot/fix-unsafe-tests-dangerous-as

Conversation

CopilotAI commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

This change addresses an intermittent failure in System.Runtime.CompilerServices.UnsafeTests.DangerousAs on jitstress ARM runs. The test asserted behavior from an invalid cast path (Unsafe.As<string>(object)) where the result is undefined.

Fixes#129678

CopilotAI requested review from Copilot and removed request for CopilotJune 24, 2026 10:53
@jkotasjkotas added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-Infrastructure labels Jun 24, 2026
@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.

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
CopilotAI requested review from Copilot and removed request for CopilotJune 24, 2026 11:27
CopilotAI changed the title [WIP] Fix test failure in UnsafeTests.DangerousAsRemove undefined-behavior UnsafeTests.DangerousAs to stabilize jitstress legJun 24, 2026
CopilotAI requested a review from jkotasJune 24, 2026 11:29
@jkotas
jkotas marked this pull request as ready for review June 24, 2026 11:32
@jkotas
jkotas requested review from EgorBo and CopilotJune 24, 2026 11:32

CopilotAI 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

This PR removes a unit test that exercises Unsafe.As<string>(object) on an incompatible runtime type, which can produce runtime/JIT-dependent behavior and intermittently fail under stress configurations (e.g., ARM jitstress). The remaining As() test still validates the supported/meaningful usage (object containing a string cast to string).

Changes:

  • Deleted UnsafeTests.DangerousAs (invalid cast scenario) from UnsafeTests.cs.
  • Left the existing As() test intact.

@MichalPetryka

Copy link
Copy Markdown
Contributor

This change addresses an intermittent failure in System.Runtime.CompilerServices.UnsafeTests.DangerousAs on jitstress ARM runs.

Do the other invalid usages in runtime like Unsafe.As<RawArrayData>(array) need to be fixed for this too then?

@jkotas

Copy link
Copy Markdown
Member

Do the other invalid usages in runtime like Unsafe.As(array) need to be fixed for this too then?

These internal runtime uses in CoreLib are in patterns that do not cause problems in the JIT currently. If they start causing problems, they will have to be fixed.

@jkotas
jkotas merged commit 5ae5630 into mainJun 26, 2026
83 of 88 checks passed
@jkotas
jkotas deleted the copilot/fix-unsafe-tests-dangerous-as branch June 26, 2026 13:43
@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview7 milestone Jun 28, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
…tress leg (#129793)
This change addresses an intermittent failure in
`System.Runtime.CompilerServices.UnsafeTests.DangerousAs` on jitstress
ARM runs. The test asserted behavior from an invalid cast path
(`Unsafe.As<string>(object)`) where the result is undefined.
Fixes#129678
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 29, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Test failure: System.Runtime.CompilerServices.UnsafeTests.DangerousAs

5 participants

@MichalPetryka@jkotas@EgorBo