Skip to content

Test failure: System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException #128019

Closed as not planned

Description

@VincentBu

Failed in: runtime-coreclr libraries-pgo 20260510.1

Failed tests:

net11.0-linux-Release-x64-fullpgo-AzureLinux.3.Amd64.Open
- System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException

Error message:

System.ArgumentOutOfRangeException : bufferSize ('-1') must be a non-negative and non-zero value. (Parameter 'bufferSize')
Actual value was -1.

Stack trace:

   at System.ArgumentOutOfRangeException.ThrowNegativeOrZero[T](T value, String paramName) in /_/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs:line 100
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) in /_/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs:line 200
   at System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException() in /_/src/libraries/System.Runtime/tests/System.IO.Tests/StreamReader/StreamReader.StringCtorTests.cs:line 63
   at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 134

Activity

  1. added
    blocking-clean-ci-optional
    on May 11, 2026
  2. added
    untriaged
    on May 11, 2026
  3. dotnet-policy-service commented on May 11, 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.

  4. MihuBot commented on May 11, 2026

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  5. dhartglassMSFT commented on May 11, 2026

    @dhartglassMSFT
    Contributor

    Failure also in linux-arm64-libraries-debug in PR testing https://dev.azure.com/dnceng-public/public/_build/results?buildId=1415481&view=results

        System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException [FAIL]
          System.ArgumentOutOfRangeException : bufferSize ('-1') must be a non-negative and non-zero value. (Parameter 'bufferSize')
          Actual value was -1.
          Stack Trace:
            /_/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs(100,0): at System.ArgumentOutOfRangeException.ThrowNegativeOrZero[T](T value, String paramName)
            /_/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs(200,0): at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
    ...
    
  6. VincentBu commented on May 18, 2026

    @VincentBu
    ContributorAuthor

    Failed in: runtime-coreclr libraries-pgo 20260517.1

    Failed tests:

    net11.0-linux-Release-x64-jitosr_stress_random-AzureLinux.3.Amd64.Open
    - System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException
    
    

    Error message:

    System.ArgumentOutOfRangeException : bufferSize ('-1') must be a non-negative and non-zero value. (Parameter 'bufferSize')
    Actual value was -1.
    

    Stack trace:

       at System.ArgumentOutOfRangeException.ThrowNegativeOrZero[T](T value, String paramName) in /_/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs:line 100
       at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Int32 bufferSize) in /_/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs:line 232
       at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) in /_/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs:line 200
       at System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException() in /_/src/libraries/System.Runtime/tests/System.IO.Tests/StreamReader/StreamReader.StringCtorTests.cs:line 63
       at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs:line 134
    
  7. VincentBu commented on Jun 29, 2026

    @VincentBu
    ContributorAuthor

    Failed in: runtime-coreclr libraries-pgo 20260627.1

    Failed tests:

    net11.0-linux-Release-x64-syntheticpgo-AzureLinux.3.Amd64.Open
    - System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException
    
    

    Error message:

    System.ArgumentOutOfRangeException : bufferSize ('-1') must be a non-negative and non-zero value. (Parameter 'bufferSize')
    Actual value was -1.
    

    Stack trace:

       at System.ArgumentOutOfRangeException.ThrowNegativeOrZero[T](T value, String paramName) in /_/src/libraries/System.Private.CoreLib/src/System/ArgumentOutOfRangeException.cs:line 100
       at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) in /_/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs:line 200
       at System.IO.Tests.StreamReader_StringCtorTests.NegativeOneBufferSize_ShouldNotThrowException() in /_/src/libraries/System.Runtime/tests/System.IO.Tests/StreamReader/StreamReader.StringCtorTests.cs:line 63
       at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
       at System.RuntimeMethodHandle.InvokeMethod(ObjectHandleOnStack target, Void** arguments, ObjectHandleOnStack sig, BOOL isConstructor, ObjectHandleOnStack result)
       at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args) in /_/src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.CoreCLR.cs:line 37
       at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 57
    
  8. adamsitnik commented on Jul 14, 2026

    @adamsitnik
    Member

    The test passes -1 to the StreamReader ctor:

    using (var sr = new StreamReader(testfile, Encoding.UTF8, true, -1))

    Which should detect the value of the argument, override it with DefaultBufferSize (const 1024) and the following check should not throw:

    if (bufferSize == -1)
    {
    bufferSize = DefaultBufferSize;
    }
    ArgumentOutOfRangeException.ThrowIfNegativeOrZero(bufferSize);

    private const int DefaultBufferSize = 1024; // Byte buffer size

    If it fails it's most likely a codegen bug.

  9. added
    area-CodeGen-coreclr
    and removed on Jul 14, 2026
  10. dotnet-policy-service commented on Jul 14, 2026

    @dotnet-policy-service
    Contributor

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

  11. removed
    untriaged
    on Jul 14, 2026
  12. added this to the 11.0.0 milestone on Jul 14, 2026
  13. JulieLeeMSFT commented on Jul 14, 2026

    @JulieLeeMSFT
    Member
  14. dhartglassMSFT commented on Jul 28, 2026

    @dhartglassMSFT
    Contributor

    Trying to repro, failure history is intermittent for this

  15. dhartglassMSFT commented on Aug 1, 2026

    @dhartglassMSFT
    Contributor

    @AndyAyersMS and I were each unable to reproduce this issue, both tried a few hundred iterations with a variety of stress configurations. closing as no repro

  16. locked and limited conversation to collaborators on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-CodeGen-coreclrblocking-clean-ci-optional

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions