Disable bad address writing interop tests with interpreter#122308
Merged
janvorli merged 3 commits intodotnet:mainfrom Dec 10, 2025
Merged
Disable bad address writing interop tests with interpreter#122308janvorli merged 3 commits intodotnet:mainfrom
janvorli merged 3 commits intodotnet:mainfrom
Conversation
This change disables all libraries interop tests that try to check that access to non-null invalid address throws access violation or null reference exception when executed using the interpreter. I've introduced a new `PlatformDetection.SupportsDirtyAccessViolations` for this purpose that is set for coreclr interpreter and for Mono and WASM too. So I have also removed the pre-existing attribute on these tests that was disabling them on Mono.
Contributor
|
Tagging subscribers to this area: @dotnet/interop-contrib |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR disables interop tests that verify access violations are thrown for invalid memory addresses when running under interpreters (CoreCLR interpreter, Mono, or WebAssembly). The change introduces a new PlatformDetection.SupportsDirtyAccessViolations property and replaces [SkipOnMono] attributes with runtime conditional checks.
- Adds detection for CoreCLR interpreter mode via environment variables (
DOTNET_InterpreterandDOTNET_InterpMode) - Introduces
SupportsDirtyAccessViolationsplatform detection property that returnsfalsefor Mono, CoreCLR interpreter, and WASM - Updates test methods to conditionally execute second assertion (with offset parameter) based on the new property
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs | Adds IsCoreClrInterpreter detection logic and SupportsDirtyAccessViolations property to identify platforms that properly throw access violations for invalid memory accesses |
| src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/IntPtrTests.cs | Removes [SkipOnMono] attributes and wraps offset-based zero pointer tests in runtime condition checks |
| src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int64Tests.cs | Removes [SkipOnMono] attributes and wraps offset-based zero pointer tests in runtime condition checks; removes trailing blank lines |
| src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int32Tests.cs | Removes [SkipOnMono] attributes and wraps offset-based zero pointer tests in runtime condition checks; removes trailing blank lines |
| src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/Int16Tests.cs | Removes [SkipOnMono] attributes and wraps offset-based zero pointer tests in runtime condition checks; removes trailing blank lines |
| src/libraries/System.Runtime.InteropServices/tests/System.Runtime.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs | Removes [SkipOnMono] attributes and wraps offset-based zero pointer tests in runtime condition checks; removes trailing blank lines |
jkotas
reviewed
Dec 8, 2025
jkotas
reviewed
Dec 8, 2025
...time.InteropServices.UnitTests/System/Runtime/InteropServices/Marshal/ReadWrite/ByteTests.cs
Outdated
Show resolved
Hide resolved
This was referenced Dec 9, 2025
jkotas
reviewed
Dec 10, 2025
jkotas
approved these changes
Dec 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change disables all libraries interop tests that try to check that access to non-null invalid address throws access violation or null reference exception when executed using the interpreter.
I've introduced a new
PlatformDetection.SupportsDirtyAccessViolationsfor this purpose that is set for coreclr interpreter and for Mono and WASM too. So I have also removed the pre-existing attribute on these tests that was disabling them on Mono.