=============================================== Bug report -- MySQL v4.04b, source distribution ===============================================
---------------------------------------------------------------- Machine specs (build machine and test machine are same machine): ---------------------------------------------------------------- Dell Inspiron 8200 laptop Windows XP Professional SP1 .NET Framework SP2 ------------------ Build description: ------------------ libmysqld.dll was built using Microsoft Visual C++ 6.0 SP5 and Microsoft Visual C++ Processor Pack SP5 (used for ASM files). We build our own version because we need to make a change so that the DLL will work with C# clients (see below for more info). -------------------- Problem description: -------------------- A C# client was built using Microsoft Visual Studio.NET. The client calls mysql_server_init(), mysql_server_end(), and mysql_server_init() again. On second call to mysql_server_init(), the exception System.NullReferenceException is thrown. >From an equivalent C++ program, an access violation occurs at the same point. Behavior is identical using debug and release builds of libmysqld.dll. -------- C# code: -------- using System; using System.Runtime.InteropServices; using System.Security; namespace Reproduce_Embedded_MySQL_crash { class Class1 { [STAThread] static void Main(string[] args) { MySqlAPI.ServerInit(0, null, null); MySqlAPI.ServerEnd(); MySqlAPI.ServerInit(0, null, null); MySqlAPI.ServerEnd(); } } class MySqlAPI { [SuppressUnmanagedCodeSecurity] [DllImport("libmysqld.dll", CharSet=System.Runtime.InteropServices.CharSet.Ansi, EntryPoint="mysql_server_init", ExactSpelling=true)] public static extern int ServerInit(int icArgs, string [] strArgs, string [] strGroups); [DllImport("libmysqld.dll", EntryPoint="mysql_server_end", ExactSpelling=true)] public static extern void ServerEnd(); } } --------- C++ code: --------- /****************************************************/ /* modified from test_dll.cpp that ships with MySQL */ /****************************************************/ #include "stdafx.h" #include <winsock.h> #include <mysql.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> const char *server_groups[] = { "test_libmysqld_SERVER", "embedded", "server", NULL }; int main(int argc, char* argv[]) { mysql_server_init(argc, argv, (char **)server_groups); mysql_server_end(); mysql_server_init(argc, argv, (char **)server_groups); mysql_server_end(); return 0; } --------------- MySQL binaries: --------------- Upon request, I can supply our debug and release builds of libmysqld.dll. ------------------------------- Source code change description: ------------------------------- There is only one change we make to the MySQL 4.04b source distribution. We define USE_TLS for the "mysys" project. The reason is that it's required for clients that use LoadLibrary(), which includes all C# clients. More information can be found in the VC++ documentation article "Rules and Limitations for TLS". ----------------------- My contact information: ----------------------- Matt Solnit <[EMAIL PROTECTED]> --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php