Bug #114086 | Item_singlerow_subselect::store may lead to memory corruption | ||
---|---|---|---|
Submitted: | 21 Feb 2024 19:41 | Modified: | 26 Feb 2024 11:00 |
Reporter: | Eldor Bekpulatov | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Charsets | Severity: | S3 (Non-critical) |
Version: | 8.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[21 Feb 2024 19:41]
Eldor Bekpulatov
[22 Feb 2024 11:25]
MySQL Verification Team
Hi Mr. Bekpulatov, Thank you for your bug report. However, when we run your test case, we can not repeat it with our 8.0.36 binary. We get the following output from the select command: mysql> SELECT * FROM t1 -> WHERE (`x1`,`x2`) = -> (SELECT `x1`,'T' FROM t1); +------+------+ | x1 | x2 | +------+------+ | tmp1 | T | +------+------+ We do not see what is wrong in the above result. Can't repeat.
[22 Feb 2024 18:02]
Eldor Bekpulatov
Please consider retrying the setup with GDB/debugger attached at those specified breakpoints. You will see the incorrect behavior. This is currently a non-issue, because v-table translations between Item_func_conv_charset and Item_cache classes are leading to "lucky" outcomes. meaning that they are calling functions that return a constant and it is discarded, but if you were to introduce any random function Item_func_conv_charset that modifies the object state, it would be lead to memory corruption. Please do look into it.
[23 Feb 2024 11:39]
MySQL Verification Team
Hi Mr. Bekpulatov, Thanks for the feedback. However, let us inform you about this forum. We could either observe wrong results or memory corruption problems. We got correct results and we have also built a binary with full ASAN instrumentation for the memory checking and it returned no memory problems. If you manage to get wrong results or reports with memory-checking software, we will be happy to reconsider this report.
[26 Feb 2024 11:00]
MySQL Verification Team
Hi Mr. Bekpulatov, Upon further analysis, we concluded that your code analysis is correct and hence, we are verifying it. This is now a verified bug affecting version 8.0 and higher.
[29 Jan 9:11]
Tor Didriksen
Posted by developer: UBSAN on head of current trunk still says sql/item_subselect.cc:1133:13: runtime error: member call on address 0x7fff18ac3a50 which does not point to an object of type 'Item_cache' 0x7fff18ac3a50: note: object is of type 'Item_string' 8f 8f 8f 8f b0 ca 8c 09 00 00 00 00 01 8f 8f 8f 8f 8f 8f 8f 00 00 00 00 00 00 00 00 00 00 00 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'Item_string' [Detaching after fork from child process 4082279] #0 0x00000156ca8b in Item_singlerow_subselect::store(unsigned int, Item*) sql/item_subselect.cc:1133:13 #1 0x00000156c5aa in Query_result_scalar_subquery::send_data(THD*, mem_root_deque<Item*> const&) sql/item_subselect.cc:890:9 #2 0x000000bafa53 in Query_expression::ExecuteIteratorQuery(THD*) sql/sql_union.cc:1136:25 #3 0x000000bb091e in Query_expression::execute(THD*) sql/sql_union.cc:1183:10 #4 0x000001569baf in Item_subselect::exec(THD*) sql/item_subselect.cc:733:36 #5 0x00000157225f in Item_singlerow_subselect::bring_value() sql/item_subselect.cc:1203:8 #6 0x0000013178aa in Arg_comparator::compare_row() sql/item_cmpfunc.cc:2099:13 #7 0x00000131db4d in Item_func_eq::val_int() sql/item_cmpfunc.cc:2586:25 #8 0x000001bda831 in FilterIterator::Read() sql/iterators/composite_iterators.cc:100:33 #9 0x000000baf87e in Query_expression::ExecuteIteratorQuery(THD*) sql/sql_union.cc:1121:36 #10 0x000000bb091e in Query_expression::execute(THD*) sql/sql_union.cc:1183:10 #11 0x000000a04398 in Sql_cmd_dml::execute_inner(THD*) sql/sql_select.cc:1128:15 #12 0x0000009ff59f in Sql_cmd_dml::execute(THD*) sql/sql_select.cc:790:7 #13 0x00000088360a in mysql_execute_command(THD*, bool) sql/sql_parse.cc:4743:29 #14 0x000000877ef6 in dispatch_sql_command(THD*, Parser_state*, bool) sql/sql_parse.cc:5405:19 #15 0x00000086a2d5 in dispatch_command(THD*, COM_DATA const*, enum_server_command) sql/sql_parse.cc:2137:7 #16 0x0000008726c1 in do_command(THD*) sql/sql_parse.cc:1480:18 #17 0x000000ddd4a3 in handle_connection(void*) sql/conn_handler/connection_handler_per_thread.cc:304:13 #18 0x000004554ed7 in pfs_spawn_thread(void*) storage/perfschema/pfs.cc:3067:3 #19 0x7ffff4f97147 in start_thread (/lib64/libc.so.6+0x71147) (BuildId: 8f0d04c433960a3a1d01ec9c4612545d44a9a405) #20 0x7ffff501b0cb in __GI___clone3 (/lib64/libc.so.6+0xf50cb) (BuildId: 8f0d04c433960a3a1d01ec9c4612545d44a9a405)
[29 Jan 9:23]
Tor Didriksen
Posted by developer: the suggested fix also fails for UBSAN, since we have: Item_cache **m_row{nullptr};
[29 Jan 11:22]
MySQL Verification Team
Thank you, Tor.