Re: Bug report: Embedded MySQL v4.04b

2002-11-27 Thread Heikki Tuuri
Matt,

thank you for the bug report.

I do not have C# in my computer. Did I understand correctly the bug does not
appear if you use the Embedded Server Library inside C++?

My first note is that you should define USE_TLS in all MySQL modules, like
Monty instructed a week ago. But I guess that cannot cause the corruption of
mysql_data_home.

I looked at the source code, and it looks like mysql_data_home should be a
pointer to a 512-character buffer called mysql_real_data_home, if you define
a datadir, and that is not the default dir (that is, .\) of the running
program. Could it be that mysql_data_home starts to point into some random
location?

I am forwarding this bug report to MySQL developers who know the mysqld
option processing best.

Best regards,

Heikki Tuuri
Innobase Oy
---
InnoDB - transactions, hot backup, and foreign key support for MySQL
See http://www.innodb.com, download MySQL-Max from http://www.mysql.com

sql query

- Original Message -
From: Matt Solnit [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: Henry Bequet [EMAIL PROTECTED]
Sent: Wednesday, November 27, 2002 7:12 PM
Subject: Bug report: Embedded MySQL v4.04b


===
Bug report -- MySQL v4.04b, source distribution
===


Machine specs (build machine and test machine are same machine):

Compaq Presario desktop
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(), passing in the command-line argument
--datadir=path, then attempts to open a connection using
mysql_init() and mysql_real_connect().  A database that is known to
exist is passed in to the mysql_real_connect() function.  The function
call fails and mysql_error() returns Unknown database 'name'.

Behavior is identical using debug and release builds of libmysqld.dll.

The problem does not occur using a C++ client.

---
Possible cause:
---
Stepping into MySQL, I find that the variable mysql_data_home is set
to the correct value when mysql_server_init() returns.  However, when
mysql_init() is entered, the value has become corrupted.


C# code:


/**/
/* you will need to customize the datadir and database name   */
/**/

using System;
using System.Security;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
  class Test
  {
[STAThread]
static void Main(string[] args)
{
  TestDirectToDLL();
}

private static void TestDirectToDLL()
{
  string[] args = new string[] {thisappname,
--datadir=c:/iter/source/ADCData};
  MySqlAPI.ServerInit(args.Length, args, null);
  IntPtr cnn = MySqlAPI.Init(IntPtr.Zero);
  IntPtr result = MySqlAPI.Connect(cnn, null, null, null,
iteration, 0, null, 0);
  if (result == IntPtr.Zero)
throw new Exception(MySqlAPI.Error(cnn));
  MySqlAPI.Close(cnn);
  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();

[SuppressUnmanagedCodeSecurity]
[DllImport(libmysqld.dll, EntryPoint=mysql_init,
ExactSpelling=true)]
public static extern IntPtr Init(IntPtr ihConnection);

[SuppressUnmanagedCodeSecurity]
[DllImport(libmysqld.dll,
   CharSet=System.Runtime.InteropServices.CharSet.Ansi,
   EntryPoint=mysql_real_connect, ExactSpelling=true)]
public static extern IntPtr Connect(IntPtr ihConnection,
  [In] string strHost, [In] string strUser, [In] string strPassword,
  [In] string strDatabaseName,
  uint iPort, [In] string strSocketName, uint iFlags
  );

[SuppressUnmanagedCodeSecurity]
[DllImport(libmysqld.dll, EntryPoint=mysql_close,
ExactSpelling=true)]
public static extern void Close(IntPtr ihConnection);

[DllImport(libmysqld.dll,
   EntryPoint=mysql_errno, ExactSpelling=true)]
public static extern uint ErrNo(IntPtr ihConnection);

[DllImport(libmysqld.dll,
   

RE: Bug report: Embedded MySQL v4.04b

2002-11-27 Thread Matt Solnit
I am looking into USE_TLS.  But yes, I see that mysql_real_data_home is
not corrupted, only mysql_data_home is.

Thanks for your response.

-- Matt

-Original Message-
From: Heikki Tuuri [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, November 27, 2002 11:40 AM
To: Matt Solnit; [EMAIL PROTECTED]
Cc: Henry Bequet
Subject: Re: Bug report: Embedded MySQL v4.04b 

Matt,

thank you for the bug report.

I do not have C# in my computer. Did I understand correctly the bug does
not
appear if you use the Embedded Server Library inside C++?

My first note is that you should define USE_TLS in all MySQL modules,
like
Monty instructed a week ago. But I guess that cannot cause the
corruption of
mysql_data_home.

I looked at the source code, and it looks like mysql_data_home should be
a
pointer to a 512-character buffer called mysql_real_data_home, if you
define
a datadir, and that is not the default dir (that is, .\) of the running
program. Could it be that mysql_data_home starts to point into some
random
location?

I am forwarding this bug report to MySQL developers who know the mysqld
option processing best.

Best regards,

Heikki Tuuri
Innobase Oy
---
InnoDB - transactions, hot backup, and foreign key support for MySQL
See http://www.innodb.com, download MySQL-Max from http://www.mysql.com

sql query

-
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




Re: bug report: Embedded MySQL v4.04b

2002-11-15 Thread Heikki Tuuri
Matt,
since you are using InnoDB, you cannot call server_end() and server_init()
again during the lifetime of the process. InnoDB does not clean up its
internal data structures in server_end().

Is there some special reason you would need to shut down the server and
open it again?
Regards,
Heikki
Innobase Oy
sql query
...
===
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