Skip to content

Test Failure: System.IO.Tests.RandomAccess_NoBuffering.ReadWriteAsyncUsingMultipleBuffers #133278

Closed

Description

@JulieLeeMSFT

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1579855
Build error leg or test failing: System.IO.Tests.RandomAccess_NoBuffering.ReadWriteAsyncUsingMultipleBuffers

    System.IO.Tests.RandomAccess_NoBuffering.ReadWriteAsyncUsingMultipleBuffers(memoryPageSized: False) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object.
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs(673,0): at System.IO.RandomAccess.WriteGatherAtOffsetAsync(SafeFileHandle handle, IReadOnlyList`1 buffers, Int64 fileOffset, CancellationToken cancellationToken)
        /_/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/RandomAccess/NoBuffering.Windows.cs(194,0): at System.IO.Tests.RandomAccess_NoBuffering.ReadWriteAsyncUsingMultipleBuffers(Boolean memoryPageSized)
        --- End of stack trace from previous location ---
    System.IO.Tests.RandomAccess_Mixed.UsingMultipleBuffers(async: True) [FAIL]
      System.NullReferenceException : Object reference not set to an instance of an object.
      Stack Trace:
        /_/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs(673,0): at System.IO.RandomAccess.WriteGatherAtOffsetAsync(SafeFileHandle handle, IReadOnlyList`1 buffers, Int64 fileOffset, CancellationToken cancellationToken)
        /_/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/RandomAccess/Mixed.Windows.cs(134,0): at System.IO.Tests.RandomAccess_Mixed.<UsingMultipleBuffers>g__Validate|2_0(SafeFileHandle handle, FileOptions options, Boolean[] syncWrites, Boolean[] syncReads)
        /_/src/libraries/System.Runtime/tests/System.IO.FileSystem.Tests/RandomAccess/Mixed.Windows.cs(99,0): at System.IO.Tests.RandomAccess_Mixed.UsingMultipleBuffers(Boolean async)

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": "System.IO.Tests.RandomAccess_NoBuffering.ReadWriteAsyncUsingMultipleBuffers(memoryPageSized: False) [FAIL]",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Report

Build Repository Test Pull Request
1584906 dotnet/runtime System.IO.Tests.RandomAccess_Mixed.UsingMultipleBuffers
1584422 dotnet/runtime System.IO.Tests.RandomAccess_WriteGatherAsync.IovLimitsAreRespected

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 2 2

Activity

  1. dotnet-policy-service commented on Sep 4, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-io
    See info in area-owners.md if you want to be subscribed.

  2. adamsitnik commented on Sep 7, 2026

    @adamsitnik
    Member

    System.NullReferenceException : Object reference not set to an instance of an object.
    Stack Trace:
    /_/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs(673,0): at System.IO.RandomAccess.WriteGatherAtOffsetAsync(SafeFileHandle handle, IReadOnlyList`1 buffers, Int64 fileOffset, CancellationToken cancellationToken)

    The code:

    private static ValueTask WriteGatherAtOffsetAsync(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset, CancellationToken cancellationToken)
    {
    if (!handle.IsAsync)
    {
    return AsyncOverSyncWithIoCancellation.InvokeAsync(static state => WriteGatherAtOffset(state.handle, state.buffers, state.fileOffset), (handle, buffers, fileOffset), cancellationToken);

    This particular line uses an argument passed to a public method that is ensured to not be null:

    public static ValueTask WriteAsync(SafeFileHandle handle, IReadOnlyList<ReadOnlyMemory<byte>> buffers, long fileOffset, CancellationToken cancellationToken = default)
    {
    ValidateInput(handle, fileOffset);
    ValidateBuffers(buffers);
    if (cancellationToken.IsCancellationRequested)
    {
    return ValueTask.FromCanceled(cancellationToken);
    }
    return WriteGatherAtOffsetAsync(handle, buffers, fileOffset, cancellationToken);

    private static void ValidateInput(SafeFileHandle handle, long fileOffset, bool allowUnseekableHandles = true)
    {
    if (handle is null)
    {
    ThrowHelper.ThrowArgumentNullException(ExceptionArgument.handle);
    }

    Even the helper that is called (IsAsync) is using a state that can't be null:

    public bool IsAsync => (GetFileOptions() & FileOptions.Asynchronous) != 0;

    internal unsafe FileOptions GetFileOptions()
    {
    FileOptions fileOptions = _fileOptions;
    if (fileOptions != UninitializedOptions)
    {
    return fileOptions;
    }
    Interop.NtDll.CreateOptions options;
    int ntStatus = Interop.NtDll.NtQueryInformationFile(
    FileHandle: this,
    IoStatusBlock: out _,
    FileInformation: &options,
    Length: sizeof(uint),
    FileInformationClass: Interop.NtDll.FileModeInformation);
    if (ntStatus != Interop.StatusOptions.STATUS_SUCCESS)
    {
    int error = (int)Interop.NtDll.RtlNtStatusToDosError(ntStatus);
    throw Win32Marshal.GetExceptionForWin32Error(error);
    }
    FileOptions result = FileOptions.None;
    if ((options & (Interop.NtDll.CreateOptions.FILE_SYNCHRONOUS_IO_ALERT | Interop.NtDll.CreateOptions.FILE_SYNCHRONOUS_IO_NONALERT)) == 0)
    {
    result |= FileOptions.Asynchronous;
    }
    if ((options & Interop.NtDll.CreateOptions.FILE_WRITE_THROUGH) != 0)
    {
    result |= FileOptions.WriteThrough;
    }
    if ((options & Interop.NtDll.CreateOptions.FILE_RANDOM_ACCESS) != 0)
    {
    result |= FileOptions.RandomAccess;
    }
    if ((options & Interop.NtDll.CreateOptions.FILE_SEQUENTIAL_ONLY) != 0)
    {
    result |= FileOptions.SequentialScan;
    }
    if ((options & Interop.NtDll.CreateOptions.FILE_DELETE_ON_CLOSE) != 0)
    {
    result |= FileOptions.DeleteOnClose;
    }
    if ((options & Interop.NtDll.CreateOptions.FILE_NO_INTERMEDIATE_BUFFERING) != 0)
    {
    result |= FileStreamHelpers.NoBuffering;
    }
    return _fileOptions = result;
    }

    Since the C# implementation was not changed for a very long time, I suspect it's some kind of a runtime bug, hence I change the area.

  3. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    and removed on Sep 7, 2026
  4. dotnet-policy-service commented on Sep 7, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  5. self-assigned this
    on Sep 7, 2026
  6. added a commit that references this issue on Sep 7, 2026
    e3845ab
  7. added this to the 12.0.0 milestone on Sep 8, 2026
  8. removed
    untriagedNew issue has not been triaged by the area owner
    on Sep 9, 2026
  9. locked and limited conversation to collaborators on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Known Build ErrorUse this to report build issues in the .NET Helix tabarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions