runtime: AccessViolationException in HttpClient.SendAsync() on macOS arm64 in .NET 9 preview.4

Description

I have an application I’m testing against .NET 9 daily builds. With the latest SDK and package versions I’m seeing System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt. errors in my tests when running on GitHub Actions’ macOS arm64 runners.

I have 9 applications I’m doing this with, but I’m only observing this issue with one of them.

Reproduction Steps

  1. Clone https://github.com/martincostello/costellobot/pull/1078/commits/18966b86239e57c468633695a1843894af31eeea
  2. Run build.ps1 on a macOS arm64 machine.

Expected behavior

The tests all pass.

Actual behavior

Lots of test failures with a stack trace similar to the below:

System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at MartinCostello.Costellobot.Infrastructure.IntegrationTests`1.PostWebhookAsync(String event, Object value, String webhookSecret, String delivery) in /_/tests/Costellobot.Tests/Infrastructure/IntegrationTests`1.cs:line 176
   at MartinCostello.Costellobot.Handlers.DeploymentStatusHandlerTests.PostWebhookAsync(DeploymentStatusDriver driver, String action) in /_/tests/Costellobot.Tests/Handlers/DeploymentStatusHandlerTests.cs:line 667
   at MartinCostello.Costellobot.Handlers.DeploymentStatusHandlerTests.Deployment_Is_Approved_For_Trusted_User_And_Dependency_When_Penultimate_Build_Skipped() in /_/tests/Costellobot.Tests/Handlers/DeploymentStatusHandlerTests.cs:line 128
--- End of stack trace from previous location ---

That corresponds to this code, but it doesn’t appear to have been recently changed:

https://github.com/dotnet/runtime/blob/8f3c687784a33aafe642368c28492244fa2f2c7f/src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs#L520-L556

Regression?

Yes.

Known Workarounds

None.

Configuration

.NET SDK 9.0.100-preview.4.24265.4

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 36 (36 by maintainers)

Most upvoted comments

I can’t repro this as of the official preview 5, so I’m going to close this on the basis it must have gotten fixed at some point.

Not observing any crashes this morning - I’ll keep any eye out as my automation updates to newer preview.5 builds daily. If I don’t observe any further crashes by the time preview.5 officially ships I’ll close this issue.

great. Thanks for the confirmation @martincostello

@janvorli Sure - I’ll try and get one of the preview 5 ones for you tomorrow.

@antonfirsov Just emailed you the link.

Sorry, I missed that. Can you send it over email? (anfirszo at companydomain).

But that probably correlates more with GitHub Actions runners moving from macOS 12 x64 to macOS 14 arm64, so it was probably broken before then and my build was just on a different arch so I didnt see it before…

At the moment my repro is just “run dotnet test” - I don’t have anything more specific at the moment.

I could maybe add something to the tests to have the tests start monitor itself (if that works?)

I’m only seeing this on macOS, not Windows or Linux, but only in this one project. I’m not specifically using lib2gitsharp anywhere, and if it is being used, I would assume it’s from an SDK or something and would/should be present in my other repos I’m testing nightlies with.

Could this be the root cause?