Bug #83115 Assertion `maybe_null' failed. handle_fatal_signal in tem_func_concat::val_str
Submitted: 23 Sep 2016 4:26 Modified: 20 Mar 2018 10:14
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Charsets Severity:S1 (Critical)
Version:8.0-dmr OS:Any
Assigned to: CPU Architecture:Any

[23 Sep 2016 4:26] Roel Van de Paar
Description:
Version: '8.0.0-dmr-debug'  socket: '/sda/MS130916-mysql-8.0.0-dmr-linux-x86_64-debug/socket.sock'  port: 15348  MySQL Community Server (GPL)
mysqld: /git/MS8.0_dbg/sql/item_strfunc.cc:808: virtual String* Item_func_concat::val_str(String*): Assertion `maybe_null' failed.
04:08:43 UTC - mysqld got signal 6 ;

+bt
#0  0x00007fd74c410741 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x00000000023fc1b9 in my_write_core (sig=6) at /git/MS8.0_dbg/mysys/stacktrace.cc:275
#2  0x0000000001b517ed in handle_fatal_signal (sig=6) at /git/MS8.0_dbg/sql/signal_handler.cc:219
#3  <signal handler called>
#4  0x00007fd74a7a75f7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#5  0x00007fd74a7a8ce8 in __GI_abort () at abort.c:90
#6  0x00007fd74a7a0566 in __assert_fail_base (fmt=0x7fd74a8f0ce8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x3103963 "maybe_null", file=file@entry=0x3103888 "/git/MS8.0_dbg/sql/item_strfunc.cc", line=line@entry=808, function=function@entry=0x3104560 <Item_func_concat::val_str(String*)::__PRETTY_FUNCTION__> "virtual String* Item_func_concat::val_str(String*)") at assert.c:92
#7  0x00007fd74a7a0612 in __GI___assert_fail (assertion=0x3103963 "maybe_null", file=0x3103888 "/git/MS8.0_dbg/sql/item_strfunc.cc", line=808, function=0x3104560 <Item_func_concat::val_str(String*)::__PRETTY_FUNCTION__> "virtual String* Item_func_concat::val_str(String*)") at assert.c:101
#8  0x000000000216fa1b in Item_func_concat::val_str (this=0x7fd71a954c88, str=0x7fd71a954ca0) at /git/MS8.0_dbg/sql/item_strfunc.cc:808
#9  0x0000000001d0bb13 in Item::save_in_field_inner (this=0x7fd71a954c88, field=0x7fd71a9d4f30, no_conversions=true) at /git/MS8.0_dbg/sql/item.cc:6677
#10 0x0000000001d0b5b6 in Item::save_in_field (this=0x7fd71a954c88, field=0x7fd71a9d4f30, no_conversions=true) at /git/MS8.0_dbg/sql/item.cc:6592
#11 0x00000000018bfe72 in store_key_item::copy_inner (this=0x7fd71a9d4ef8) at /git/MS8.0_dbg/sql/sql_select.h:1007
#12 0x00000000018c004f in store_key_const_item::copy_inner (this=0x7fd71a9d4ef8) at /git/MS8.0_dbg/sql/sql_select.h:1069
#13 0x0000000001850576 in store_key::copy (this=0x7fd71a9d4ef8) at /git/MS8.0_dbg/sql/sql_select.h:914
#14 0x00000000018b61ee in create_ref_for_key (join=0x7fd71a9d3f30, j=0x7fd71a9d4340, org_keyuse=0x7fd71a9d46c0, used_tables=0) at /git/MS8.0_dbg/sql/sql_select.cc:1372
#15 0x00000000022ba11b in JOIN::extract_func_dependent_tables (this=0x7fd71a9d3f30) at /git/MS8.0_dbg/sql/sql_optimizer.cc:5531
#16 0x00000000022b8b7f in JOIN::make_join_plan (this=0x7fd71a9d3f30) at /git/MS8.0_dbg/sql/sql_optimizer.cc:4999
#17 0x00000000022ad7fa in JOIN::optimize (this=0x7fd71a9d3f30) at /git/MS8.0_dbg/sql/sql_optimizer.cc:377
#18 0x00000000018b5284 in SELECT_LEX::optimize (this=0x7fd71a953b98, thd=0x7fd71a819000) at /git/MS8.0_dbg/sql/sql_select.cc:1028
#19 0x000000000191d7e8 in SELECT_LEX_UNIT::optimize (this=0x7fd71a953e58, thd=0x7fd71a819000) at /git/MS8.0_dbg/sql/sql_union.cc:691
#20 0x00000000018b52e0 in SELECT_LEX::optimize (this=0x7fd71a950bb0, thd=0x7fd71a819000) at /git/MS8.0_dbg/sql/sql_select.cc:1034
#21 0x000000000191d7e8 in SELECT_LEX_UNIT::optimize (this=0x7fd71a950e70, thd=0x7fd71a819000) at /git/MS8.0_dbg/sql/sql_union.cc:691
#22 0x0000000002188087 in Item_subselect::exec (this=0x7fd71a957ce0) at /git/MS8.0_dbg/sql/item_subselect.cc:625
#23 0x0000000002189fd9 in Item_singlerow_subselect::val_str (this=0x7fd71a957ce0, str=0x7fd71a957cf8) at /git/MS8.0_dbg/sql/item_subselect.cc:1293
#24 0x0000000001d0bb13 in Item::save_in_field_inner (this=0x7fd71a957ce0, field=0x7fd71a9cab50, no_conversions=false) at /git/MS8.0_dbg/sql/item.cc:6677
#25 0x0000000001d0b5b6 in Item::save_in_field (this=0x7fd71a957ce0, field=0x7fd71a9cab50, no_conversions=false) at /git/MS8.0_dbg/sql/item.cc:6592
#26 0x000000000225cb0e in sp_eval_expr (thd=0x7fd71a819000, result_field=0x7fd71a9cab50, expr_item_ptr=0x7fd71a958288) at /git/MS8.0_dbg/sql/sp.cc:2450
#27 0x0000000001806fef in sp_rcontext::set_return_value (this=0x7fd71a9cf030, thd=0x7fd71a819000, return_value_item=0x7fd71a958288) at /git/MS8.0_dbg/sql/sp_rcontext.cc:158
#28 0x00000000017fe599 in sp_instr_freturn::exec_core (this=0x7fd71a9581c0, thd=0x7fd71a819000, nextp=0x7fd74ca00a38) at /git/MS8.0_dbg/sql/sp_instr.cc:1352
#29 0x00000000017fc162 in sp_lex_instr::reset_lex_and_exec_core (this=0x7fd71a9581c0, thd=0x7fd71a819000, nextp=0x7fd74ca00a38, open_tables=true) at /git/MS8.0_dbg/sql/sp_instr.cc:376
#30 0x00000000017fcd73 in sp_lex_instr::validate_lex_and_execute_core (this=0x7fd71a9581c0, thd=0x7fd71a819000, nextp=0x7fd74ca00a38, open_tables=true) at /git/MS8.0_dbg/sql/sp_instr.cc:679
#31 0x0000000001800614 in sp_lex_instr::execute (this=0x7fd71a9581c0, thd=0x7fd71a819000, nextp=0x7fd74ca00a38) at /git/MS8.0_dbg/sql/sp_instr.h:315
#32 0x00000000017f4869 in sp_head::execute (this=0x7fd71a91f030, thd=0x7fd71a819000, merge_da_on_success=true) at /git/MS8.0_dbg/sql/sp_head.cc:2224
#33 0x00000000017f5c04 in sp_head::execute_function (this=0x7fd71a91f030, thd=0x7fd71a819000, argp=0x7fd71a82de30, argcount=1, return_value_fld=0x7fd71a9cab50) at /git/MS8.0_dbg/sql/sp_head.cc:2730
#34 0x0000000001d86830 in Item_func_sp::execute_impl (this=0x7fd71a82dd88, thd=0x7fd71a819000) at /git/MS8.0_dbg/sql/item_func.cc:8842
#35 0x0000000001d865b2 in Item_func_sp::execute (this=0x7fd71a82dd88) at /git/MS8.0_dbg/sql/item_func.cc:8774
#36 0x0000000001d8dc9f in Item_func_sp::val_str (this=0x7fd71a82dd88, str=0x7fd74ca01dd0) at /git/MS8.0_dbg/sql/item_func.h:3236
#37 0x0000000001d0d983 in Item::send (this=0x7fd71a82dd88, protocol=0x7fd71a81a1f0, buffer=0x7fd74ca01dd0) at /git/MS8.0_dbg/sql/item.cc:7367
#38 0x0000000001833c69 in THD::send_result_set_row (this=0x7fd71a819000, row_items=0x7fd71a82d1e0) at /git/MS8.0_dbg/sql/sql_class.cc:2791
#39 0x000000000224e7b4 in Query_result_send::send_data (this=0x7fd71a86ff88, items=...) at /git/MS8.0_dbg/sql/query_result.cc:82
#40 0x0000000001843274 in JOIN::exec (this=0x7fd71a9cac00) at /git/MS8.0_dbg/sql/sql_executor.cc:177
#41 0x00000000018b3a6f in handle_query (thd=0x7fd71a819000, lex=0x7fd71a81b338, result=0x7fd71a86ff88, added_options=0, removed_options=0) at /git/MS8.0_dbg/sql/sql_select.cc:194
#42 0x0000000001874e55 in execute_sqlcom_select (thd=0x7fd71a819000, all_tables=0x0) at /git/MS8.0_dbg/sql/sql_parse.cc:4863
#43 0x000000000186f414 in mysql_execute_command (thd=0x7fd71a819000, first_level=true) at /git/MS8.0_dbg/sql/sql_parse.cc:2775
#44 0x0000000001875c14 in mysql_parse (thd=0x7fd71a819000, parser_state=0x7fd74ca034e0) at /git/MS8.0_dbg/sql/sql_parse.cc:5233
#45 0x000000000186c3b8 in dispatch_command (thd=0x7fd71a819000, com_data=0x7fd74ca03c70, command=COM_QUERY) at /git/MS8.0_dbg/sql/sql_parse.cc:1481
#46 0x000000000186b244 in do_command (thd=0x7fd71a819000) at /git/MS8.0_dbg/sql/sql_parse.cc:1043
#47 0x0000000001b43af1 in handle_connection (arg=0x7fd71a16c080) at /git/MS8.0_dbg/sql/conn_handler/connection_handler_per_thread.cc:301
#48 0x000000000242bf29 in pfs_spawn_thread (arg=0x7fd71a1e4f20) at /git/MS8.0_dbg/storage/perfschema/pfs.cc:2282
#49 0x00007fd74c40bdc5 in start_thread (arg=0x7fd74ca04700) at pthread_create.c:308
#50 0x00007fd74a868ced in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
DROP DATABASE test;
set names binary;
SET collation_connection=utf0_czech_ci;
SELECT sys.ps_is_consumer_enabled('events_stages_histONg');
[23 Sep 2016 5:14] MySQL Verification Team
Hello Roel,

Thank you for the report and test case.
Observed that 8.0 debug build is affected.

Thanks,
Umesh
[14 Jul 2017 2:22] Roel Van de Paar
Most of my bugs are real bugs, I hope :)

How is it going Tor?
[20 Mar 2018 10:14] Jon Stephens
Documented fix in the MySQL 8.0.11 changelog as follows:

        When processing a query with a subquery, the subquery is no
        longer optimized if outer query is known to produce an empty
        result; in such cases, EXPLAIN now shows "Not optimized, outer
        query is empty".

        This change is made because, when the table used by the outer
        query is found empty at optimization, this sets the join column
        to NULL even when defined as not nullable, which leads to a
        conflict when optimizing the subquery.

        An exception is made if the outer query has aggregates without
        any GROUP BY; this means that it has a non-empty result, and
        that any subquery in the SELECT list must be evaluated and
        optimized, which reopens the nullability issue, which is now
        handled correctly.

Closed.