Bug #37362 | Crash in do_field_eq | ||
---|---|---|---|
Submitted: | 12 Jun 2008 11:30 | Modified: | 3 Aug 2009 23:05 |
Reporter: | Philip Stoev | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 6.0-falcon, 5.0, 5.1, 6.0 bzr | OS: | Any |
Assigned to: | Gleb Shchepa | CPU Architecture: | Any |
Tags: | regression |
[12 Jun 2008 11:30]
Philip Stoev
[2 Sep 2008 13:37]
Philip Stoev
Setting to open so that the bug verification team can take over.
[23 Mar 2009 21:38]
Sveta Smirnova
Thank you for the report. Verified as described. Backtrace from 5.1: Thread 1 (process 4827): #0 0x002ce402 in __kernel_vsyscall () #1 0x0046264f in pthread_kill () from /lib/libpthread.so.0 #2 0x085a46c5 in my_write_core (sig=11) at stacktrace.c:310 #3 0x0824c685 in handle_segfault (sig=11) at mysqld.cc:2513 #4 <signal handler called> #5 0x08190d80 in Item_field::print (this=0xa295ae0, str=0xb2b0c3f4, query_type=QT_ORDINARY) at item.cc:5434 #6 0x0816f657 in st_select_lex::print_order (str=0xb2b0c3f4, order=0xa28ac58, query_type=QT_ORDINARY) at sql_lex.cc:1985 #7 0x082eef48 in st_select_lex::print (this=0xa289638, thd=0xa230c78, str=0xb2b0c3f4, query_type=QT_ORDINARY) at sql_select.cc:16634 #8 0x08207766 in subselect_single_select_engine::print (this=0xa2854a8, str=0xb2b0c3f4, query_type=QT_ORDINARY) at item_subselect.cc:2438 #9 0x0820153f in Item_subselect::print (this=0xa285420, str=0xb2b0c3f4, query_type=QT_ORDINARY) at item_subselect.cc:317 #10 0x081842c1 in Item::print_item_w_name (this=0xa285420, str=0xb2b0c3f4, query_type=QT_ORDINARY) at item.cc:451 #11 0x082eedbe in st_select_lex::print (this=0xa289238, thd=0xa230c78, str=0xb2b0c3f4, query_type=QT_ORDINARY) at sql_select.cc:16595 #12 0x0816f786 in st_select_lex_unit::print (this=0xa2893c8, str=0xb2b0c3f4, query_type=QT_ORDINARY) at sql_lex.cc:1953 #13 0x082ee6ab in TABLE_LIST::print (this=0xa285d48, thd=0xa230c78, str=0xb2b0c3f4, query_type=QT_ORDINARY) at sql_select.cc:16487 #14 0x082ee9f6 in print_join (thd=0xa230c78, str=0xb2b0c3f4, tables=0xa2320d4, query_type=QT_ORDINARY) at sql_select.cc:16390 #15 0x082eee2a in st_select_lex::print (this=0xa232010, thd=0xa230c78, str=0xb2b0c3f4, query_type=QT_ORDINARY) at sql_select.cc:16606 #16 0x0816f786 in st_select_lex_unit::print (this=0xa231da0, str=0xb2b0c3f4, query_type=QT_ORDINARY) at sql_lex.cc:1953 #17 0x0825b7d0 in execute_sqlcom_select (thd=0xa230c78, all_tables=0xa285d48) at sql_parse.cc:4895 #18 0x08261be1 in mysql_execute_command (thd=0xa230c78) at sql_parse.cc:2204 #19 0x0826af74 in mysql_parse (thd=0xa230c78, inBuf=0xa288cc0 "EXPLAIN EXTENDED SELECT int_key FROM ( SELECT ( SELECT COUNT( pk ) FROM ( SELECT AVG(\nint_nokey ) FROM D AS X WHERE X . int_key < 76 ORDER BY int_nokey LIMIT 20 ) AS X WHERE X\n. int_nokey < 83 GROUP"..., length=317, found_semicolon=0xb2b0d2fc) at sql_parse.cc:5831 #20 0x0826bbb0 in dispatch_command (command=COM_QUERY, thd=0xa230c78, packet=0xb2a7d021 "", packet_length=317) at sql_parse.cc:1216 #21 0x0826cdce in do_command (thd=0xa230c78) at sql_parse.cc:857 #22 0x08259a05 in handle_one_connection (arg=0xa230c78) at sql_connect.cc:1115 #23 0x0045fbd4 in start_thread () from /lib/libpthread.so.0 #24 0x003b74fe in clone () from /lib/libc.so.6
[23 Mar 2009 21:40]
Sveta Smirnova
6.0 backtrace like 5.1 in my case: #0 0x002ce402 in __kernel_vsyscall () #0 0x002ce402 in __kernel_vsyscall () #1 0x0046264f in pthread_kill () from /lib/libpthread.so.0 #2 0x088240fb in my_write_core (sig=11) at stacktrace.c:309 #3 0x082bf3a0 in handle_segfault (sig=11) at mysqld.cc:2689 #4 <signal handler called> #5 0x082004c4 in Item_field::print (this=0xa7990f8, str=0xa7f0d084, query_type=QT_ORDINARY) at item.cc:5624 #6 0x081df05b in st_select_lex::print_order (str=0xa7f0d084, order=0xa5f4128, query_type=QT_ORDINARY) at sql_lex.cc:2055 #7 0x083702e8 in st_select_lex::print (this=0xa5b72d8, thd=0xa5ba5b8, str=0xa7f0d084, query_type=QT_ORDINARY) at sql_select.cc:22125 #8 0x08277b50 in subselect_single_select_engine::print (this=0xa5f4258, str=0xa7f0d084, query_type=QT_ORDINARY) at item_subselect.cc:2783 #9 0x08271a51 in Item_subselect::print (this=0xa5f41b8, str=0xa7f0d084, query_type=QT_ORDINARY) at item_subselect.cc:383 #10 0x081f34a7 in Item::print_item_w_name (this=0xa5f41b8, str=0xa7f0d084, query_type=QT_ORDINARY) at item.cc:450 #11 0x0837015e in st_select_lex::print (this=0xa5b6ea8, thd=0xa5ba5b8, str=0xa7f0d084, query_type=QT_ORDINARY) at sql_select.cc:22086 #12 0x081df18a in st_select_lex_unit::print (this=0xa5b7040, str=0xa7f0d084, query_type=QT_ORDINARY) at sql_lex.cc:2023 #13 0x0836f999 in TABLE_LIST::print (this=0xa5f4d90, thd=0xa5ba5b8, str=0xa7f0d084, query_type=QT_ORDINARY) at sql_select.cc:21978 #14 0x0836fc48 in print_table_array (thd=0xa5ba5b8, str=0xa7f0d084, table=0xa7996c8, end=0xa7996cc) at sql_select.cc:21834 #15 0x0836febe in print_join (thd=0xa5ba5b8, str=0xa7f0d084, tables=0xa5bb8b0, query_type=QT_ORDINARY) at sql_select.cc:21903 #16 0x083701ca in st_select_lex::print (this=0xa5bb7ec, thd=0xa5ba5b8, str=0xa7f0d084, query_type=QT_ORDINARY) at sql_select.cc:22097 #17 0x081df18a in st_select_lex_unit::print (this=0xa5bb554, str=0xa7f0d084, query_type=QT_ORDINARY) at sql_lex.cc:2023 #18 0x082ce382 in execute_sqlcom_select (thd=0xa5ba5b8, all_tables=0xa5f4d90) at sql_parse.cc:4752 #19 0x082d4017 in mysql_execute_command (thd=0xa5ba5b8) at sql_parse.cc:2069 #20 0x082dced3 in mysql_parse (thd=0xa5ba5b8, inBuf=0xa5b66c8 "EXPLAIN EXTENDED SELECT int_key FROM ( SELECT ( SELECT COUNT( pk ) FROM ( SELECT AVG(\nint_nokey ) FROM D AS X WHERE X . int_key < 76 ORDER BY int_nokey LIMIT 20 ) AS X WHERE X\n. int_nokey < 83 GROUP"..., length=317, found_semicolon=0xa7f0df20) at sql_parse.cc:5783 #21 0x082dd915 in dispatch_command (command=COM_QUERY, thd=0xa5ba5b8, packet=0xa7e7e021 "", packet_length=317) at sql_parse.cc:1009 #22 0x082dec79 in do_command (thd=0xa5ba5b8) at sql_parse.cc:691 #23 0x082cca67 in handle_one_connection (arg=0xa5ba5b8) at sql_connect.cc:1146 #24 0x0045fbd4 in start_thread () from /lib/libpthread.so.0 #25 0x003b74fe in clone () from /lib/libc.so.6
[23 Mar 2009 21:42]
Sveta Smirnova
shorter test
Attachment: bug37362.test (application/octet-stream, text), 379.17 KiB.
[24 Mar 2009 6:50]
Sveta Smirnova
Bug was repeatable with version 5.1.23, then not repeatable with versions 5.1.30-5.1.32 (didn't check when it was reintroduced though) and 6.0.8, then repeatable again with current development sources.
[24 Mar 2009 17:12]
Sveta Smirnova
Bug is repeatable with current 5.0, 5.1 and 6.0 sources.
[1 Apr 2009 21:56]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/71146 2722 Gleb Shchepa 2009-04-02 Bug #37362: Crash in do_field_eq EXPLAIN EXTENDED of nested query containing a error: 1054 Unknown column '...' in 'field list' may cause a server crash. Parse error like described above forces a call to JOIN::destroy() on malformed subquery. That JOIN::destroy function closes and frees temporary tables. However, temporary fields of these tables may be listed in st_select_lex::group_list of outer query, and that st_select_lex may not cleanup them properly. So, after the JOIN::destroy call that st_select_lex::group_list may have Item_field objects with dangling pointers to freed temporary table Field objects. That caused a crash. To prevent dangling pointers, 1) a list of temporary table fields has been added to JOIN class; 2) JOIN::destroy has been modified to cleanup temporary table fields. modified: mysql-test/r/subselect3.result mysql-test/t/subselect3.test sql/sql_select.cc sql/sql_select.h
[3 Apr 2009 15:44]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/71332 2722 Gleb Shchepa 2009-04-03 Bug #37362: Crash in do_field_eq EXPLAIN EXTENDED of nested query containing a error: 1054 Unknown column '...' in 'field list' may cause a server crash. Parse error like described above forces a call to JOIN::destroy() on malformed subquery. That JOIN::destroy function closes and frees temporary tables. However, temporary fields of these tables may be listed in st_select_lex::group_list of outer query, and that st_select_lex may not cleanup them properly. So, after the JOIN::destroy call that st_select_lex::group_list may have Item_field objects with dangling pointers to freed temporary table Field objects. That caused a crash. modified: mysql-test/r/subselect3.result mysql-test/t/subselect3.test sql/sql_select.cc
[29 Apr 2009 18:15]
Timour Katchaounov
Review discussion with Gleb: <timour> gleb, quick question <timour> in <timour> JOIN::destroy() <timour> you added: <timour> + { /* Cleanup items referencing temporary table columns */ <timour> + List_iterator_fast<Item> it(tmp_all_fields3); <timour> + Item *item; <timour> + while ((item= it++)) <timour> + item->cleanup(); <timour> + } <timour> gleb, this is unconditional, however <timour> looking at how tmp_all_fields3 is used, <timour> one case that it is initialized inside an IF statement: <timour> inside <timour> JOIN::exec() <timour> { <timour> .... <timour> if (curr_join->group || curr_join->tmp_table_param.sum_func_count || <timour> (procedure && (procedure->flags & PROC_GROUP))) <timour> { <timour> ... <gleb> timour: looking <timour> initalize and modify tmp_all_fields3 <timour> ... <timour> } <timour> } <timour> gleb, thus, it makes sense to change your patch as: <timour> if (tmp_all_fields3 is non-empty) <timour> { <timour> cleanup all items in tmp_all_fields3 <timour> } <timour> gleb, then another question - <gleb> timour: agree (OTOH isn't this change equivalent to my patch? ;-) <timour> gleb, not exactly, as with this change we allocate an iterator only if really needed. <timour> gleb, and it is clearer, otherwise why cleanup something that shouldn't be cleaned up. <timour> gleb, then naturally, I would like you to investigate how do we cleanup the contents of <timour> tmp_all_fields[1,2] <gleb> timour: FYI: cleanup of tmp_all_fields2 like tmp_all_fields3 is probably ok, but tmp_all_fields1 is not (I'm just running tests and looking at gdb traces) <timour> gleb, could be - my point was that we should not wait for the next similar bug if there are other similar cases. <timour> gleb, also, please add a comment why tmp_all_fields[2,3] can be cleaned up, but tmp_all_fields1 cannot. <gleb> timour: I see. but additional investigation is not trivial (need some more time) <gleb> timour: ok <timour> gleb, if tmp_all_fields2 needs cleanup, could you add a test. <gleb> timour: I think I can
[30 Apr 2009 8:36]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/73090 2722 Gleb Shchepa 2009-04-30 Bug #37362: Crash in do_field_eq EXPLAIN EXTENDED of nested query containing a error: 1054 Unknown column '...' in 'field list' may cause a server crash. Parse error like described above forces a call to JOIN::destroy() on malformed subquery. That JOIN::destroy function closes and frees temporary tables. However, temporary fields of these tables may be listed in st_select_lex::group_list of outer query, and that st_select_lex may not cleanup them properly. So, after the JOIN::destroy call that st_select_lex::group_list may have Item_field objects with dangling pointers to freed temporary table Field objects. That caused a crash. @ mysql-test/r/subselect3.result Added test case for bug #37362. @ mysql-test/t/subselect3.test Added test case for bug #37362. @ sql/sql_select.cc Bug #37362: Crash in do_field_eq The JOIN::destroy function has been modified to cleanup temporary table column items.
[28 May 2009 7:40]
Bugs System
Pushed into 5.0.83 (revid:joro@sun.com-20090528073529-q9b8s60vlpu28fny) (version source revid:gshchepa@mysql.com-20090430192037-9p1etcynkglte2j3) (merge vers: 5.0.82) (pib:6)
[28 May 2009 8:13]
Bugs System
Pushed into 5.1.36 (revid:joro@sun.com-20090528073639-yohsb4q1jzg7ycws) (version source revid:mats@sun.com-20090511132802-nnkiyb2huih1tklz) (merge vers: 5.1.35) (pib:6)
[30 May 2009 2:35]
Paul DuBois
Noted in 5.0.83, 5.1.36 changelogs. If a query was such as to produce the error "1054 Unknown column '...' in 'field list'," using EXPLAIN EXTENDED with the query could cause a server crash. Setting report to NDI pending push into 6.0.x.
[3 Aug 2009 23:05]
Paul DuBois
Noted in 5.4.4 changelog.
[10 Aug 2009 17:53]
Paul DuBois
Noted in 5.0.82sp1 changelog.
[10 Aug 2009 18:59]
Bugs System
Pushed into 5.0.85 (revid:build@mysql.com-20090810185326-yr4orhpwq09e3y50) (version source revid:build@mysql.com-20090810185326-yr4orhpwq09e3y50) (merge vers: 5.0.85) (pib:11)
[12 Aug 2009 22:54]
Paul DuBois
Noted in 5.4.2 changelog because next 5.4 version will be 5.4.2 and not 5.4.4.
[15 Aug 2009 2:11]
Paul DuBois
Ignore previous comment about 5.4.2.
[25 Aug 2009 9:23]
Bugs System
Pushed into 5.1.39 (revid:jperkin@sun.com-20090824091334-6ktgrhq218vl7zq1) (version source revid:joerg@mysql.com-20090813203300-nnskc3aofxydzi85) (merge vers: 5.1.39) (pib:11)
[26 Aug 2009 13:45]
Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46]
Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48]
Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32]
Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[14 Sep 2009 16:02]
Bugs System
Pushed into 5.4.4-alpha (revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (version source revid:alik@sun.com-20090914155317-m1g9wodmndzdj4l1) (merge vers: 5.4.4-alpha) (pib:11)
[1 Oct 2009 5:58]
Bugs System
Pushed into 5.1.39-ndb-6.3.28 (revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (version source revid:jonas@mysql.com-20091001055605-ap2kiaarr7p40mmv) (merge vers: 5.1.39-ndb-6.3.28) (pib:11)
[1 Oct 2009 7:25]
Bugs System
Pushed into 5.1.39-ndb-7.0.9 (revid:jonas@mysql.com-20091001072547-kv17uu06hfjhgjay) (version source revid:jonas@mysql.com-20091001071652-irejtnumzbpsbgk2) (merge vers: 5.1.39-ndb-7.0.9) (pib:11)
[1 Oct 2009 13:25]
Bugs System
Pushed into 5.1.39-ndb-7.1.0 (revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (version source revid:jonas@mysql.com-20091001123013-g9ob2tsyctpw6zs0) (merge vers: 5.1.39-ndb-7.1.0) (pib:11)
[5 Oct 2009 10:50]
Bugs System
Pushed into 5.1.39-ndb-6.2.19 (revid:jonas@mysql.com-20091005103850-dwij2dojwpvf5hi6) (version source revid:jonas@mysql.com-20090930185117-bhud4ek1y0hsj1nv) (merge vers: 5.1.39-ndb-6.2.19) (pib:11)
[8 Oct 2009 20:13]
Paul DuBois
The 5.4 fix has been pushed to 5.4.2.