Bug #96692 Adding a function once mysql.func is converted to MYISAM leads to crash
Submitted: 29 Aug 2019 9:47 Modified: 30 Aug 2019 6:54
Reporter: Hrvoje Matijakovic Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S6 (Debug Builds)
Version:8.0.17 OS:Linux
Assigned to: CPU Architecture:x86

[29 Aug 2019 9:47] Hrvoje Matijakovic
Description:
I'm able to reproduce this on debug only. Release build doesn't result in a crash:

gdb:
Core was generated by `/sdc/MS230819-mysql-8.0.17-linux-x86_64-debug/bin/mysqld --no-defaults --basedi'.
Program terminated with signal 6, Aborted.
#0  0x00007fed38b5c9d1 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:59
59        val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
+bt
#0  0x00007fed38b5c9d1 in __pthread_kill (threadid=<optimized out>, signo=6) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:59
#1  0x0000000004580cc8 in my_write_core (sig=6) at /sdc/MS-8.0.17_dbg/mysys/stacktrace.cc:305
#2  0x00000000032f4d64 in handle_fatal_signal (sig=6) at /sdc/MS-8.0.17_dbg/sql/signal_handler.cc:168
#3  <signal handler called>
#4  0x00007fed36c5f2c7 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:55
#5  0x00007fed36c609b8 in __GI_abort () at abort.c:90
#6  0x00007fed36c580e6 in __assert_fail_base (fmt=0x7fed36db3020 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5c51200 "trn_ctx->is_active(Transaction_ctx::SESSION)", file=file@entry=0x5c4f360 "/sdc/MS-8.0.17_dbg/sql/log_event.cc", line=line@entry=3977, function=function@entry=0x5c562e0 <_ZZN15Query_log_eventC4EP3THDPKcmbbbibE19__PRETTY_FUNCTION__> "Query_log_event::Query_log_event(THD*, const char*, size_t, bool, bool, bool, int, bool)") at assert.c:92
#7  0x00007fed36c58192 in __GI___assert_fail (assertion=0x5c51200 "trn_ctx->is_active(Transaction_ctx::SESSION)", file=0x5c4f360 "/sdc/MS-8.0.17_dbg/sql/log_event.cc", line=3977, function=0x5c562e0 <_ZZN15Query_log_eventC4EP3THDPKcmbbbibE19__PRETTY_FUNCTION__> "Query_log_event::Query_log_event(THD*, const char*, size_t, bool, bool, bool, int, bool)") at assert.c:101
#8  0x00000000041c5386 in Query_log_event::Query_log_event (this=0x7fed355fde60, thd_arg=0x7fecdd021000, query_arg=0x7fecdd071028 "CREATE FUNCTION version_tokens_show RETURNS STRING SONAME 'version_token.so'", query_length=76, using_trans=true, immediate=false, suppress_use=false, errcode=0, ignore_cmd_internals=false, __in_chrg=<optimized out>, __vtt_parm=<optimized out>) at /sdc/MS-8.0.17_dbg/sql/log_event.cc:3977
#9  0x000000000420d40c in THD::binlog_query (this=0x7fecdd021000, qtype=THD::STMT_QUERY_TYPE, query_arg=0x7fecdd071028 "CREATE FUNCTION version_tokens_show RETURNS STRING SONAME 'version_token.so'", query_len=76, is_trans=true, direct=false, suppress_use=false, errcode=0) at /sdc/MS-8.0.17_dbg/sql/binlog.cc:11329
#10 0x00000000031c033e in write_bin_log (thd=0x7fecdd021000, clear_error=true, query=0x7fecdd071028 "CREATE FUNCTION version_tokens_show RETURNS STRING SONAME 'version_token.so'", query_length=76, is_trans=true) at /sdc/MS-8.0.17_dbg/sql/sql_table.cc:1085
#11 0x000000000322cc35 in mysql_create_function (thd=0x7fecdd021000, udf=0x7fecdd024b10) at /sdc/MS-8.0.17_dbg/sql/sql_udf.cc:684
#12 0x000000000312b84d in mysql_execute_command (thd=0x7fecdd021000, first_level=true) at /sdc/MS-8.0.17_dbg/sql/sql_parse.cc:3701
#13 0x00000000031304fe in mysql_parse (thd=0x7fecdd021000, parser_state=0x7fed35600af0) at /sdc/MS-8.0.17_dbg/sql/sql_parse.cc:5221
#14 0x0000000003125aa9 in dispatch_command (thd=0x7fecdd021000, com_data=0x7fed35601b90, command=COM_QUERY) at /sdc/MS-8.0.17_dbg/sql/sql_parse.cc:1755
#15 0x000000000312400c in do_command (thd=0x7fecdd021000) at /sdc/MS-8.0.17_dbg/sql/sql_parse.cc:1270
#16 0x00000000032dffcd in handle_connection (arg=0x7fece5c525c0) at /sdc/MS-8.0.17_dbg/sql/conn_handler/connection_handler_per_thread.cc:302
#17 0x0000000004d28926 in pfs_spawn_thread (arg=0x7fed34c69fe0) at /sdc/MS-8.0.17_dbg/storage/perfschema/pfs.cc:2854
#18 0x00007fed38b57dd5 in start_thread (arg=0x7fed35602700) at pthread_create.c:307
#19 0x00007fed36d2702d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

How to repeat:
ALTER TABLE mysql.func ENGINE=MYISAM;
CREATE FUNCTION version_tokens_show RETURNS STRING SONAME 'version_token.so';
[30 Aug 2019 6:54] Umesh Shastry
Hello Hrvoje Matijakovic,

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

regards,
Umesh