Wrong result/valgrind warning in Item_sum_hybrid::any_value()
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MariaDB |
Fix Released
|
High
|
Timour Katchaounov |
Bug Description
Executing a particular prepared statement twice caused the following valgrind warning:
==21705== Thread 9:
==21705== Invalid read of size 1
==21705== at 0x82120E2: Item_sum_
==21705== by 0x8202D5D: Item_func_
==21705== by 0x8202E5C: Item_func_
==21705== by 0x81C37D3: Item::val_bool() (item.cc:187)
==21705== by 0x820EA75: Item_cond_
==21705== by 0x832CACC: evaluate_
==21705== by 0x832C737: sub_select(JOIN*, st_join_table*, bool) (sql_select.
==21705== by 0x832BB09: do_select(JOIN*, List<Item>*, st_table*, Procedure*) (sql_select.
==21705== by 0x8310749: JOIN::exec() (sql_select.
==21705== by 0x83128A1: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_
==21705== by 0x8458F0F: mysql_derived_
==21705== by 0x845881A: mysql_handle_
==21705== by 0x82F34F1: open_and_
==21705== by 0x82AEA18: open_and_
==21705== by 0x82A7D1F: execute_
==21705== by 0x829ED7D: mysql_execute_
crash backtrace:
# 2011-05-13T20:06:54 #3 0x0828c410 in handle_segfault (sig=11) at mysqld.cc:2778
# 2011-05-13T20:06:54 #4 <signal handler called>
# 2011-05-13T20:06:54 #5 0x082120e2 in Item_sum_
# 2011-05-13T20:06:54 #6 0x08202d5e in Item_func_
# 2011-05-13T20:06:54 #7 0x08202e5d in Item_func_
# 2011-05-13T20:06:54 #8 0x081c37d4 in Item::val_bool (this=0xa831dc8) at item.cc:187
# 2011-05-13T20:06:54 #9 0x0820ea76 in Item_cond_
# 2011-05-13T20:06:54 #10 0x0832cacd in evaluate_
# 2011-05-13T20:06:54 #11 0x0832c738 in sub_select (join=0xa84d9a8, join_tab=0xa858db8, end_of_
# 2011-05-13T20:06:54 #12 0x0832cda5 in evaluate_
# 2011-05-13T20:06:54 #13 0x0832c880 in sub_select (join=0xa84d9a8, join_tab=0xa858bd4, end_of_
# 2011-05-13T20:06:54 #14 0x0832bb0a in do_select (join=0xa84d9a8, fields=0x0, table=0xa77f530, procedure=0x0) at sql_select.cc:13602
# 2011-05-13T20:06:54 #15 0x0831074a in JOIN::exec (this=0xa84d9a8) at sql_select.cc:2114
# 2011-05-13T20:06:54 #16 0x083128a2 in mysql_select (thd=0xa78aa10, rref_pointer_
# 2011-05-13T20:06:54 group=0x0, having=0x0, proc_param=0x0, select_
# 2011-05-13T20:06:54 #17 0x08458f10 in mysql_derived_
# 2011-05-13T20:06:54 #18 0x0845881b in mysql_handle_
# 2011-05-13T20:06:54 #19 0x082f34f2 in open_and_
# 2011-05-13T20:06:54 #20 0x082aea19 in open_and_
# 2011-05-13T20:06:54 #21 0x082a7d20 in execute_
# 2011-05-13T20:06:54 #22 0x0829ed7e in mysql_execute_
# 2011-05-13T20:06:54 #23 0x0835258c in Prepared_
# 2011-05-13T20:06:54 #24 0x08351a74 in Prepared_
# 2011-05-13T20:06:54 at sql_prepare.cc:3352
# 2011-05-13T20:06:54 #25 0x08350390 in mysql_sql_
# 2011-05-13T20:06:54 #26 0x0829eda7 in mysql_execute_
# 2011-05-13T20:06:54 #27 0x082aa4d7 in mysql_parse (thd=0xa78aa10, rawbuf=0xa796130 "EXECUTE prep_stmt_21349 /* TRANSFORM_
# 2011-05-13T20:06:54 found_semicolon
# 2011-05-13T20:06:54 #28 0x0829ca07 in dispatch_command (command=COM_QUERY, thd=0xa78aa10, packet=0xa78cc11 "EXECUTE prep_stmt_21349 /* TRANSFORM_
# 2011-05-13T20:06:54 packet_length=63) at sql_parse.cc:1215
# 2011-05-13T20:06:54 #29 0x0829be65 in do_command (thd=0xa78aa10) at sql_parse.cc:904
# 2011-05-13T20:06:54 #30 0x08298f18 in handle_
# 2011-05-13T20:06:54 #31 0x00821919 in start_thread () from /lib/libpthread
# 2011-05-13T20:06:54 #32 0x0076acce in clone () from /lib/libc.so.6
A test case will be attached shortly.
Related branches
Changed in maria: | |
milestone: | none → 5.3 |
summary: |
- Crash/valgrind warning in Item_sum_hybrid::any_value() + Wrong result/valgrind warning in Item_sum_hybrid::any_value() |
Changed in maria: | |
status: | New → Confirmed |
Changed in maria: | |
assignee: | Igor Babaev (igorb-seattle) → Timour Katchaounov (timour) |
importance: | Undecided → High |
Changed in maria: | |
status: | Confirmed → In Progress |
Changed in maria: | |
status: | In Progress → Fix Committed |
Changed in maria: | |
status: | Fix Committed → Fix Released |
I could no longer reproduce the crash, however the second execution produces
a different (wrong) result compared to the first execution. Thus renaming the bug.
It doesn't matter which subquery strategy was used during prepare/execution.
MariaDB [test]> execute st1; --+---- ----+-- ------+ --+---- ----+-- ------+ --+---- ----+-- ------+
+------
| field1 | field2 | field3 |
+------
| 0 | NULL | m |
+------
1 row in set (0.00 sec)
MariaDB [test]> execute st1; --+---- ----+-- ------+ --+---- ----+-- ------+ --+---- ----+-- ------+
+------
| field1 | field2 | field3 |
+------
| 0 | NULL | NULL |
+------