Add deterministic NativeAOT regression smoke test for GC restricted reverse P/Invoke assert path - #130459
Add deterministic NativeAOT regression smoke test for GC restricted reverse P/Invoke assert path#130459MichalStrehovsky with Copilot wants to merge 11 commits into
Conversation
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
…restore original assert Co-authored-by: MichalStrehovsky <13110571+MichalStrehovsky@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/tests/Interop/COM/ComWrappers/GcRestrictedCalloutReversePInvoke/GcRestrictedCalloutReversePInvoke.csproj:21
- This project uses xUnit ([Fact] in Program.cs) but unlike the other ComWrappers interop test projects in this directory it doesn’t reference $(TestLibraryProjectPath). As-is, this will likely fail to compile due to missing xUnit/test infrastructure references.
<ItemGroup>
<Compile Include="../Common.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<CMakeProjectReference Include="../MockReferenceTrackerRuntime/CMakeLists.txt" />
</ItemGroup>
</Project>
|
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. |
|
We now have a test that hits the assert without this fix and works with the fix. Is the test valuable enough to keep? Cc @VSadov |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
src/tests/Interop/COM/ComWrappers/GcRestrictedCalloutReversePInvoke/GcRestrictedCalloutReversePInvoke.csproj:16
- This test project uses xUnit ([Fact] in Program.cs) but the csproj is missing the standard that all other ComWrappers test projects in this directory use. Without it, the project may not compile or may miss test infrastructure references.
<ItemGroup>
<Compile Include="../Common.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
src/tests/Interop/COM/ComWrappers/GcRestrictedCalloutReversePInvoke/GcRestrictedCalloutReversePInvoke.csproj:5
- This project is described as a NativeAOT smoke test in the PR metadata, but it’s currently added under src/tests/Interop/COM/ComWrappers (not src/tests/nativeaot/SmokeTests). If it’s intended to run in the NativeAOT smoke test legs, it likely needs to live under the nativeaot test tree (or have additional wiring) to be discovered/executed there.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<CLRTestPriority>0</CLRTestPriority>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Test interacts with GC collections, also needed for CLRTestTargetUnsupported below -->
src/tests/Interop/COM/ComWrappers/GcRestrictedCalloutReversePInvoke/Program.cs:63
- Use xUnit assertions for test failures instead of throwing Exception. This keeps failures consistent with the rest of the ComWrappers tests and produces cleaner output in test reports.
if (!observedConcurrentGen2)
{
throw new Exception($"Timed out after {timeout} waiting for a concurrent Gen2 GC. Initial count: {initialGen2Collections}, final count: {GC.CollectionCount(2)}.");
}
src/coreclr/nativeaot/Runtime/thread.inl:208
- The PR description states the change is test-only and does not modify product behavior, but this hunk changes a runtime assertion condition in Thread::InlineTryFastReversePInvoke. Please update the PR description/scope accordingly (or split the runtime change into the appropriate fix PR if this PR is meant to be test-only).
if (IsDoNotTriggerGcSet())
{
// We expect this scenario only when EE is stopped or we're on a GC worker thread.
ASSERT(ThreadStore::IsTrapThreadsRequested() || IsGCSpecial());
// no need to do anything
Resolves #110683.
This adds a focused NativeAOT regression test for the GC restricted callout path where background GC can invoke managed
[UnmanagedCallersOnly]callbacks and hitThread::InlineTryFastReversePInvokeassertion behavior prior to the runtime fix. The change is test-only and is intended to reliably drive the failing pre-fix path, not modify product behavior.Test added
src/tests/nativeaot/SmokeTests/GcRestrictedCalloutReversePInvoke/Repro wiring
ComWrappers.RegisterForTrackerSupport(...).MockReferenceTrackerRuntimeso GC restricted tracker callbacks are active (GCStopCollectionpath).Deterministic triggering
GC.Collect(..., blocking:false)).SpinWait+ elapsed bound) instead of unbounded probabilistic loops.Scope/guards
Expectation documented
dotnet/runtime#110683and states expected behavior:Environment limitation observed while validating command
ReleaseNativeAOT targeted test build failed due to missingMicrosoft.DotNet.ILCompiler.SingleEntry.targets;Checkedconfiguration was used for targeted execution.