Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in MySqlConnection.Cancel #1506

Closed
dmathijs opened this issue Aug 15, 2024 · 3 comments
Closed

NullReferenceException in MySqlConnection.Cancel #1506

dmathijs opened this issue Aug 15, 2024 · 3 comments

Comments

@dmathijs
Copy link

dmathijs commented Aug 15, 2024

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?

@bgrainger
Copy link
Member

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

bgrainger added a commit that referenced this issue Aug 17, 2024
Signed-off-by: Bradley Grainger <bgrainger@gmail.com>
@dmathijs
Copy link
Author

Thank you!

@bgrainger
Copy link
Member

Fixed in 2.4.0.

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

No branches or pull requests

2 participants