Skip to content

NullReferenceException in MySqlConnection.Cancel  #1506

Closed

Description

@dmathijs

MySqlConnector version: 2.3.1
Server type (MySQL, MariaDB, Aurora, etc.) and version: MariaDb
.NET version: 8.0.302
(Optional) ORM NuGet packages and versions: Pomelo.EntityFrameworkCore.MySql

Today I got this stacktrace on my server:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at MySqlConnector.MySqlConnection.Cancel(ICancellableCommand command, Int32 commandId, Boolean isCancel) in /_/src/MySqlConnector/MySqlConnection.cs:line 762
   at MySqlConnector.MySqlCommand.CancelCommandForTimeout() in /_/src/MySqlConnector/MySqlCommand.cs:line 439
   at MySqlConnector.Utilities.TimerQueue.Callback(Object obj) in /_/src/MySqlConnector/Utilities/TimerQueue.cs:line 98
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool)
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

I noticed that back in 2022, there was a fix done for this exact issue:

However, this seems to be re-factored away and it seems like this bug was re-introduced at some point.
000f586
e82f091

The problem is that I don't know enough about the code-base to know whether adding null conditional operators is allowed, can someone give me some pointers?

Activity

  1. bgrainger commented on Aug 17, 2024

    @bgrainger
    Member

    This does look like a bug that was reintroduced in e82f091; thanks for the analysis.

  2. added a commit that references this issue on Aug 17, 2024
    ed0fad8
  3. dmathijs commented on Aug 28, 2024

    @dmathijs
    Author

    Thank you!

  4. bgrainger commented on Nov 12, 2024

    @bgrainger
    Member

    Fixed in 2.4.0.

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions