Skip to content

Test failure: SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds fails intermittently on Linux #133012

Description

@rzikm

Test failure

System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds is failing intermittently on Linux (Ubuntu.2604.Amd64.Open, Alpine.324.Amd64.Open, Alpine.Edge.Amd64.Open, AzureLinux.3.0.ArmArch.Open, Alpine.324.Arm64.Open) in the inner loop across the runtime, runtime-coreclr crossgen2, and runtime-nativeaot-outerloop pipelines.

Error message

Assert.False() Failure
Expected: False
Actual:   True

Stack trace:

at System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds() in /_/src/libraries/System.Net.Sockets/tests/FunctionalTests/Connect.Unix.cs:line 230

Frequency

11 builds on main plus ~34 PR runs over the past 14 days, exclusively on Linux queues. Ongoing since 2026-08-19.

Analysis

The failing assertion is at Connect.Unix.cs:230:

src/libraries/System.Net.Sockets/tests/FunctionalTests/Connect.Unix.cs

bool completedAsync = client.ConnectAsync(saea);
if (!completedAsync)
{
    tcs.SetResult();
}

await tcs.Task;

Assert.Equal(SocketError.Success, saea.SocketError);
Assert.True(client.Blocking);

// On Apple and Android platforms, TFO (connectx/sendto) may complete the connect+send
// in a single syscall, so the socket can end up blocking even on the async path.
// On Linux, async connect always leaves the socket non-blocking when
// buffer > 0 because SendToAsync is pending.
if (!completedAsync || PlatformDetection.IsApplePlatform || PlatformDetection.IsAndroid)
{
    Assert.False(IsSocketNonBlocking(client));   // <-- line 230
}
else
{
    Assert.True(IsSocketNonBlocking(client));
}

On loopback the ConnectAsync(saea) with a send buffer can complete synchronously (completedAsync == false). The test then takes the line-230 branch and asserts the socket has been restored to blocking mode (IsSocketNonBlocking == False). Intermittently the socket is still non-blocking (Actual: True), because a pending async send left over from the connect+send path keeps the descriptor in non-blocking mode.

In other words, the test's assumption that a synchronously-completing ConnectAsync + buffer always restores blocking mode does not hold on Linux loopback: the sync-vs-async classification races with whether the underlying SendToAsync is still pending. This looks like a test-logic race (the !completedAsync branch is not a reliable proxy for "the socket has been restored to blocking mode"), though it may also point at a blocking-mode-restore gap in the sync-completion path.

Suggested fix

Make the blocking-mode assertion tolerant of the sync-completion-with-pending-send case on Linux (e.g. only assert blocking mode when there is genuinely no pending send), or restore blocking mode deterministically before completing the synchronous connect+send path. Until then, filing a Known Build Error so Build Analysis can auto-match this failure.

Sample console log

https://helixr1107v0xdcypoyl9e7f.blob.core.windows.net/dotnet-runtime-refs-heads-main-986da17b21c84d32af/System.Net.Sockets.Tests/1/console.063f084e.log?helixlogtype=result

Known issue error message

Fill the error message using known issues.

{
  "ErrorPattern": "System\\.Net\\.Sockets\\.Tests\\.SocketBlockingModeTransitionTests\\.ConnectAsync_WithBuffer_Succeeds",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Known issue validation

Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1575764
Error message validated: [System\.Net\.Sockets\.Tests\.SocketBlockingModeTransitionTests\.ConnectAsync_WithBuffer_Succeeds]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 9/1/2026 1:14:11 PM UTC

Report

Build Repository Test Pull Request
1577757 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132927
1577670 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1577740 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133042
1577658 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132732
1577635 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133040
1577580 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133044
1577535 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #131877
1577527 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132639
1577508 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1577432 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #131398
1577421 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132420
1577296 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133031
1577137 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1577221 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132419
1576993 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132926
1577014 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132953
1576918 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133017
1576948 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132456
1576863 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132930
1576744 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133013
1576710 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #131675
1576701 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #131789
1576625 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133002
1575764 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
23 24 24

Metadata

Metadata

Assignees

No one assigned

    Labels

    Known Build ErrorUse this to report build issues in the .NET Helix tabarea-System.Net.SocketsuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions