Bug #33886 Problem in mysql_library_end() Embedded C API function
Submitted: 16 Jan 2008 12:43 Modified: 30 Jan 2009 23:14
Reporter: Oleg Yaroshevych Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S2 (Serious)
Version:5.1.22, 5.1.30 OS:Windows (XP SP2)
Assigned to: CPU Architecture:Any
Tags: embedded

[16 Jan 2008 12:43] Oleg Yaroshevych
Description:
mysql_library_end() produces an access violation error. Probably it also corrupts InnoDB storage (I encountered problems in mysql_query() when running tests several times, but this may be caused by my configuration problems).

How to repeat:
Use following code to reproduce the problem (I use VS2005):

using namespace std;

static char *server_options[] = { "mysql_test", "--defaults-file=my.ini", NULL };
int num_elements = (sizeof(server_options) / sizeof(char *)) - 1;
static char *server_groups[] = { "embedded", "server",  "this_program_SERVER",  (char *)NULL};

int main(void)
{
  mysql_library_init(num_elements, server_options, server_groups);
  MYSQL *mysql = mysql_init(NULL);
  mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "libmysqld_client");
  mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);
  int clientflag = CLIENT_FOUND_ROWS | CLIENT_MULTI_QUERIES | CLIENT_MULTI_STATEMENTS;
  mysql_real_connect(mysql, NULL,NULL,NULL, "mysql", 0,NULL,clientflag);

  cout << mysql_get_server_info(mysql) << endl;

  if (mysql_query(mysql, "drop database if exists test") != 0)
  {
    cout << "error dropping database" << endl;
    return 1;
  }

  if (mysql_query(mysql, "create database test") != 0)
  {
    cout << "error creating database" << endl;
    return 1;
  }

  if (mysql_query(mysql, "create table test.emp (empno int primary key, ename varchar(10), job varchar(9), mgr int, hiredate datetime, sal float, comm float, deptno int) engine=InnoDB default charset=latin1") != 0)
  {
    cout << "error creating table" << endl;
    return 1;
  }

  if (mysql_query(mysql, "insert into test.emp values (7369,'SMITH','CLERK',7902,'1980-12-17',800,NULL,20)") != 0)
  {
    cout << "insert error" << endl;
    return 1;
  }

  mysql_close(mysql);
  cout << "closing library..." << endl;
  mysql_library_end();
  cout << "ok" << endl;
  return 0;
}

-----------------------------
%windir%\my.ini file:

[embedded]
basedir=d:/servers/embedded/
datadir=d:/servers/embedded/data/
max_allowed_packet=167772160
-----------------------------
Output for 5.1.22:

5.1.22-rc-community-debug-embedded
closing library...
Press any key to continue . . .
-----------------------------
Output for 4.1.22:

4.1.22-community-embedded
closing library...
ok
Press any key to continue . . .
[25 Jan 2008 13:30] Susanne Ebrecht
Many thanks for writing a bug report.

Which connector do you use?
[28 Jan 2008 14:49] Oleg Yaroshevych
> Which connector do you use?
Hello, I'm a developer of MyDirect .NET - ADO.NET data provider for MySQL Server.
[14 Feb 2008 5:34] Valeriy Kravchuk
Please, try to repeat with a newer version, 5.1.23, and inform about the results.
[15 Mar 2008 0: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".
[19 Mar 2008 17:10] Susanne Ebrecht
Oleg,

we still need to know if you have this issue also by using our newest MySQL version 5.1.23.
[20 Mar 2008 10:50] Oleg Yaroshevych
Ok. I'll try to reproduce it this week.
[25 Mar 2008 20:38] Oleg Yaroshevych
My test works fine with release version of the dll (in both Release and Debug configurations of my test project), but the problem still exists in Debug version. I used compiled binaries from mysql-noinstall-5.1.23-rc-win32.zip.

Here is the output:

4.1.22-community-embedded
closing library...
ok
Press any key to continue . . .

5.1.22-rc-community-debug-embedded
closing library...
Press any key to continue . . .

5.1.23-rc-community-debug-embedded
closing library...
Press any key to continue . . .

5.1.23-rc-community-embedded
closing library...
ok
Press any key to continue . . .

Here is the call stack (I used Debug version of .dll):

libmysqld.dll!innobase_release_stat_resources(trx_struct * trx=0xfeeefeee)  Line 481 + 0x3 bytes	C++
libmysqld.dll!innobase_release_temporary_latches(handlerton * hton=0x00b75858, THD * thd=0x01122080)  Line 544 + 0x9 bytes	C++
libmysqld.dll!ha_innobase::close()  Line 2443 + 0x10 bytes	C++
libmysqld.dll!closefrm(st_table * table=0x0113f870, int free_share=1)  Line 1944 + 0x13 bytes	C++
libmysqld.dll!intern_close_table(st_table * table=0x0113f870)  Line 854 + 0xb bytes	C++
libmysqld.dll!free_cache_entry(st_table * table=0x0113f870)  Line 876 + 0x9 bytes	C++
libmysqld.dll!hash_delete(st_hash * hash=0x10996454, unsigned char * record=0x0113f870)  Line 529 + 0xc bytes	C
libmysqld.dll!close_cached_tables(THD * thd=0x00000000, TABLE_LIST * tables=0x00000000, int have_lock=0, int wait_for_refresh=0, int wait_for_placeholders=0)  Line 941 + 0x10 bytes	C++
libmysqld.dll!table_cache_free()  Line 133 + 0xf bytes	C++
libmysqld.dll!clean_up(int print_message=0)  Line 1207	C++
libmysqld.dll!end_embedded_server()  Line 552 + 0x7 bytes	C++
libmysqld.dll!mysql_server_end()  Line 204	C
mysql_library_end_test.exe!main()  Line 48	C++
[2 Jul 2008 16:28] Valeriy Kravchuk
Please, try to repeat with a newer version, 5.1.25, and inform about the results.
[2 Aug 2008 23: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".
[14 Dec 2008 11:28] Irina T
I have the same error in version 5.1.30. What can I do?
[30 Dec 2008 22:23] MySQL Verification Team
I couldn't repeat this issue with latest source server, however I compiled with VS2003, so I will test with VS2005.

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>bug33886
5.1.31-nt-embedded-debug
closing library...
ok

C:\mysql>
[30 Dec 2008 23:14] MySQL Verification Team
I was not able to repeat compiling with VS2005, I compiled the embedded server and the client, so I have a question: you compiled both too?. Thanks in advance.
[31 Jan 2009 0: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".