Bug #1663 | Server crash if connection is closed without mysql_stmt_close call | ||
---|---|---|---|
Submitted: | 25 Oct 2003 16:49 | Modified: | 20 Jan 2004 10:25 |
Reporter: | Dmitry Lenev | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.1 | OS: | |
Assigned to: | Alexey Botchkov | CPU Architecture: | Any |
[25 Oct 2003 16:49]
Dmitry Lenev
[25 Oct 2003 23:44]
Dmitry Lenev
Actually the crash can be reproduced even with mysql_stmt_close(); You just need to execute some query via the same connection after mysql_execute() but before mysql_stmt_close(): ... stmt= mysql_prepare(mysql,"SELECT i FROM test_bg1663 WHERE i IN (?,?,?)",44); bind[0].buffer= (char *)int_data; bind[0].buffer_type= FIELD_TYPE_LONG; bind[0].is_null= 0; bind[2]= bind[1]= bind[0]; bind[1].buffer= (char *)(int_data + 1); bind[2].buffer= (char *)(int_data + 2); rc= mysql_bind_param(stmt, bind); rc= mysql_execute(stmt); rc = mysql_query(mysql, "SELECT * FROM test_bg1663"); result = mysql_store_result(mysql); /* ... fetch and free result here */ /* Server should crash here :( */ mysql_stmt_close(stmt); I suspect that the reason of this bug is following: When we are executing prep stmt we allocate some memory in current mem_root (in this example in Item_func_in::fix_length_and_dec()), and put a pointer to created object in Item_func_in::array which is allocated in prep stmt memroot. After that we execute next query, so memory in current mem_root is destroyed... But Item_func_in::array still references it , so then we do delete array; in ~Item_func_in() we receive SIGSEGV. Probably we will have the same problem with any Item which destroys objects allocated during execution (in fix_fields() or in val()) in its destructor (do we have any?)...
[14 Dec 2003 16:02]
Dmitry Lenev
See also another manifestation of this problem in bug report #2099
[14 Dec 2003 20:46]
MySQL Verification Team
Dmitri I am changing the Priority from Medium to High due to similar issues at customer side.
[20 Jan 2004 10:25]
Alexey Botchkov
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html Additional info: Fixed with the big cleanup()-related changeset