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
1581388 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1581241 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133179
1581296 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132584
1581290 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132401
1581072 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132965
1580784 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133165
1580798 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1580661 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133159
1580644 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133157
1580513 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133154
1580462 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133000
1580413 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133151
1580259 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1580178 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1580162 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133028
1580000 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133137
1579972 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132579
1579975 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133107
1579857 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132863
1579673 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1579537 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132908
1579649 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133128
1579645 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132396
1579608 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132965
1579541 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #131877
1579548 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132927
1579326 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133116
1579225 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133111
1579163 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133107
1579120 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133028
1579015 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133099
1578779 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133000
1578548 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132836
1578480 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133075
1578356 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133069
1578322 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132687
1578283 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #131794
1578265 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133068
1578223 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132953
1575286 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132975
1578184 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132617
1578166 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133011
1578110 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #130050
1577981 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #133060
1577982 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds
1577994 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132420
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
1577520 dotnet/runtime System.Net.Sockets.Tests.SocketBlockingModeTransitionTests.ConnectAsync_WithBuffer_Succeeds #132970
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
18 71 71

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Known Build ErrorUse this to report build issues in the .NET Helix tabarea-System.Net.Socketsblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'untriagedNew 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