Bug #112933 In the async void pattern, an exception can cause the application to crash.
Submitted: 2 Nov 2023 1:55 Modified: 27 Aug 2024 8:45
Reporter: King Chen Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.1.0 OS:Linux
Assigned to: MySQL Verification Team CPU Architecture:Any
Tags: async void, crash

[2 Nov 2023 1:55] King Chen
Description:
when an exception is throwed in
MySql.Data.MySqlClient.MySqlPoolManager.CleanIdleConnections(Object obj), the application is crashed.

The method use "async void" instead of "async task", which is not suggested.

How to repeat:
not sure, but I recorded stacks as below:
Aborted (core dumped)
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'key')
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext executionContext, Action`1 callback, TState& state)
at MySql.Data.MySqlClient.MySqlPoolManager.CleanIdleConnections(Object obj)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
at MySql.Data.MySqlClient.MySqlPoolManager.<>c.<CleanIdleConnections>b__29_0(String key)
at System.Collections.Generic.Dictionary`2.FindValue(TKey key)

Suggested fix:
use "async task" instead of "async void"
[2 Nov 2023 12:16] MySQL Verification Team
Hello!

Thank you for the bug report.
Could you please provide repeatable test case (sample project, etc. - please make it as private if you prefer) to reproduce this issue at our end?

Regards,
Ashwini Patil
[3 Dec 2023 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[27 Aug 2024 8:45] King Chen
fixed