Skip to content

NullReferenceException in SNIPacket.ReadFromStreamAsync #2026

Closed as not planned

Description

@MahmudX

Sentry is reporting this issue a lot (below the exact stack trace). Can you help?

System.NullReferenceException: Object reference not set to an instance of an object.
  ?, in void SNIPacket.ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback)
  ?, in uint SNITCPHandle.ReceiveAsync(ref SNIPacket packet)
  ?, in uint SNIMarsConnection.ReceiveAsync(ref SNIPacket packet)
  ?, in void SNIMarsConnection.HandleReceiveComplete(SNIPacket packet, uint sniErrorCode)
  ?, in void SNIPacket.ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback)+(Task<int> t) => { }
  File "Task.cs", line 2381, in void Task.ExecuteWithThreadLocal(ref Task currentTaskSlot, Thread threadPoolThread)

Activity

  1. JRahnama commented on May 1, 2023

    @JRahnama
    Contributor

    @MahmudX can you provide more info and possibly a repro that could help us reproducing the issue?

  2. JRahnama commented on May 8, 2023

    @JRahnama
    Contributor

    From the error message I could say this is similar to issue #422. Can you follow on that thread if you see similarity please.

  3. SuperXCode commented on Feb 11, 2024

    @SuperXCode

    The error is still there

    Object reference not set to an instance of an object

    at System.Data.SqlClient.SNI.SNIPacket.WriteToStream (System.IO.Stream stream) [0x00000] in :0
    at System.Data.SqlClient.SNI.SNITCPHandle.Send (System.Data.SqlClient.SNI.SNIPacket packet) [0x0000c] in :0
    at System.Data.SqlClient.SNI.SNIMarsConnection.Send (System.Data.SqlClient.SNI.SNIPacket packet) [0x0000c] in :0
    at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket (System.Data.SqlClient.SNI.SNISMUXFlags flags) [0x00034] in :0
    at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose () [0x00014] in :0
    at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose () [0x00052] in :0
    at System.Data.SqlClient.TdsParserSessionPool.PutSession (System.Data.SqlClient.TdsParserStateObject session) [0x00020] in :0
    at System.Data.SqlClient.TdsParser.PutSession (System.Data.SqlClient.TdsParserStateObject session) [0x00008] in :0
    at System.Data.SqlClient.TdsParserStateObject.CloseSession () [0x0000c] in :0
    at System.Data.SqlClient.SqlCommand.PutStateObject () [0x00011] in :0
    at System.Data.SqlClient.SqlCommand.ReliablePutStateObject () [0x00000] in :0
    at System.Data.SqlClient.SqlCommand.EndExecuteReader (System.IAsyncResult asyncResult) [0x00022] in :0
    at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <509dd36094194d04bf311b5a53d207f9>:0

  4. David-Engel commented on Jun 15, 2024

    @David-Engel
    Contributor

    We don't support SDS in this repo. If it can be repro'd in MDS, please file an issue.

  5. johnwc commented on Sep 21, 2024

    @johnwc

    We are seeing this in our logging as well. What is causing it? @David-Engel what does SDS and MDS stand for?

  6. johnwc commented on Sep 21, 2024

    @johnwc

    The stack trace from Entity Framework 8.0.8.

    System.NullReferenceException: Object reference not set to an instance of an object.
      File "SNITcpHandle.cs", line 902, in uint SNITCPHandle.ReceiveAsync(ref SNIPacket packet)
        packet.ReadFromStreamAsync(_stream);
      File "SNIMarsConnection.cs", line 144, in uint SNIMarsConnection.ReceiveAsync(ref SNIPacket packet)
        return response;
      File "SNIMarsConnection.cs", line 342, in void SNIMarsConnection.HandleReceiveComplete(SNIPacket packet, uint sniErrorCode)
        sniErrorCode = ReceiveAsync(ref packet);
      File "Task.cs", line 2349, in void Task.ExecuteWithThreadLocal(ref Task currentTaskSlot, Thread threadPoolThread)
        ExecutionContext.RunFromThreadPoolDispatchLoop(threadPoolThread, ec, s_ecCallback, this);
    
  7. JRahnama commented on Sep 21, 2024

    @JRahnama
    Contributor

    what does SDS and MDS stand for?

    SDS: System.Data.SqlClient
    MDS: Microsoft.Data.SqlClient

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

    No labels
    No labels

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions