Bug #95242 NULL reference exception on open() method of MySql.Data.MySqlClient.MySqlConnect
Submitted: 3 May 2019 16:26 Modified: 7 May 2019 15:54
Reporter: Frantz ROCHARD Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:8.0.16 OS:Windows
Assigned to: CPU Architecture:Any

[3 May 2019 16:26] Frantz ROCHARD
Description:
NULL reference exception ONLY on the FIRST open() call method of MySql.Data.MySqlClient.MySqlConnect. 

Code OK with 8.0.15
Code CRASH with 8.0.16

Detail of exception:

-		$exception	{"La valeur ne peut pas être null.\r\nNom du paramètre : element"}	System.ArgumentNullException
+		Data	{System.Collections.ListDictionaryInternal}	System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
		HResult	-2147467261	int
		HelpLink	null	string
+		IPForWatsonBuckets	0x73e5efbd	System.UIntPtr
+		InnerException	null	System.Exception
		IsTransient	false	bool
		Message	"La valeur ne peut pas être null.\r\nNom du paramètre : element"	string
		ParamName	"element"	string
		RemoteStackTrace	null	string
		Source	"mscorlib"	string
		StackTrace	"   à System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)"	string
+		TargetSite	{System.Attribute[] GetCustomAttributes(System.Reflection.Assembly, System.Type, Boolean)}	System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
		WatsonBuckets	null	object
		_HResult	-2147467261	int
		_className	null	string
+		_data	{System.Collections.ListDictionaryInternal}	System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
		_dynamicMethods	null	object
+		_exceptionMethod	{System.Attribute[] GetCustomAttributes(System.Reflection.Assembly, System.Type, Boolean)}	System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
		_exceptionMethodString	null	string
		_helpURL	null	string
+		_innerException	null	System.Exception
+		_ipForWatsonBuckets	0x73e5efbd	System.UIntPtr
		_message	"La valeur ne peut pas être null."	string
		_remoteStackIndex	0	int
		_remoteStackTraceString	null	string
+		_safeSerializationManager	{System.Runtime.Serialization.SafeSerializationManager}	System.Runtime.Serialization.SafeSerializationManager
		_source	"mscorlib"	string
+		_stackTrace	{sbyte[24]}	object {sbyte[]}
		_stackTraceString	null	string
		_watsonBuckets	null	object
		_xcode	-532462766	int
+		_xptrs	0x00000000	System.IntPtr
		m_paramName	"element"	string
+		Membres statiques		

How to repeat:
protected MySql.Data.MySqlClient.MySqlConnection ConnectMySQL() {

MySql.Data.MySqlClient.MySqlConnection connection = new MySql.Data.MySqlClient.MySqlConnection {
  ConnectionString = new MySql.Data.MySqlClient.MySqlConnectionStringBuilder() {
     SslMode = MySql.Data.MySqlClient.MySqlSslMode.None,
     CharacterSet = "utf8",
     ConnectionTimeout = 120,
     ConnectionProtocol = MySql.Data.MySqlClient.MySqlConnectionProtocol.Tcp,
     Database = "base",
     Port = 3306,
     Password = "password",
     UserID = "user",
     Server = "localhost"
   }.ToString(),
};

try {
    connection.Open();  // -> CRASH IF FIRST CALL ONLY
} catch {
    connection.Open(); // -> ALLWAYS OK
};
return connection;
}
[7 May 2019 13:53] MySQL Verification Team
Please provide a console test case file showing the issue?.
[7 May 2019 15:15] Frantz ROCHARD
Call stack when crash…

mscorlib.dll!System.Attribute.GetCustomAttributes(System.Reflection.Assembly element, System.Type attributeType, bool inherit)
mscorlib.dll!System.Attribute.GetCustomAttribute(System.Reflection.Assembly element, System.Type attributeType, bool inherit)
mscorlib.dll!System.Reflection.CustomAttributeExtensions.GetCustomAttribute<System.Runtime.Versioning.TargetFrameworkAttribute>(System.Reflection.Assembly element)
MySql.Data.dll!MySql.Data.MySqlClient.MySqlConnectAttrs.InitFramework()
MySql.Data.dll!MySql.Data.MySqlClient.MySqlConnectAttrs.MySqlConnectAttrs()
[Transition Natif à Managé]		Frame annoté
[Transition Managé à Natif]		Frame annoté
MySql.Data.dll!MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs()
MySql.Data.dll!MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(bool reset)
MySql.Data.dll!MySql.Data.MySqlClient.NativeDriver.Authenticate(string authMethod, bool reset)
MySql.Data.dll!MySql.Data.MySqlClient.NativeDriver.Open()
MySql.Data.dll!MySql.Data.MySqlClient.Driver.Open()
MySql.Data.dll!MySql.Data.MySqlClient.Driver.Create(MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings)
MySql.Data.dll!MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
MySql.Data.dll!MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
MySql.Data.dll!MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
MySql.Data.dll!MySql.Data.MySqlClient.MySqlPool.GetConnection()
MySql.Data.dll!MySql.Data.MySqlClient.MySqlConnection.Open()
[7 May 2019 15:34] Frantz ROCHARD
Sorry… the description isn't exact 

The first call of MySqlConnection.Open() threw null reference exception (at MySqlConnectAttrs.InitFramework()) , but the connection is opened correctly and works…
[7 May 2019 15:54] Frantz ROCHARD
Sorry …

Visual studio intecept the exception, but this exception has no impact to the excecution… 

Can close the subject.