[MDEV-29539] [ERROR] mysqld got exception 0xc0000005 Created: 2022-09-14  Updated: 2022-09-15

Status: Open
Project: MariaDB Server
Component/s: Data Manipulation - Update
Affects Version/s: 10.6.9
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Kyungsuk Yoo Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Environment:

. OS: Windows11 Pro 21H2 (OS build 22000.978)
. Processor: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz 2.30 GHz
. RAM: 32GB


Attachments: PNG File DB_version.png     File DESKTOP-VSFJFLF.err     File my.ini     File mysqld.dmp     Text File sql_errors.log     Text File table_ddl.txt    
Issue Links:
Duplicate
duplicates MDEV-19811 Crash with prepared statement Open

 Description   

Hello,

I'm implementing a program to draw diagram showing connections between nodes with information of which node(s) go(es) to which node(s).
For this purpose, table LN_MODEL_LAYER has:
. rowseq and colseq: coordinates in the grid
. ghostrowseq: coordinates of the copy of a node when the original node is too far.

And table LN_MODEL_SEQ shows the connections between nodes where
. fromseq means seq of source in LN_MODEL_LAYER
. seq means seq(=destination) in LN_MODEL_LAYER

To implement this a massive program in Node.js runs, but MariaDB stops in the middle with a log like this in Node.js side:
error: read ECONNRESET

{"code":"ECONNRESET","errno":-4077,"timestamp":"2022-09-15 00:12:27"}

error: ERROR

{"timestamp":"2022-09-15 00:12:27"}

error: CONNECTION CLOSED

{"timestamp":"2022-09-15 00:12:27"}

error: GENERAL ERROR

{"timestamp":"2022-09-15 00:12:27"}

error: errno: -4077

{"timestamp":"2022-09-15 00:12:27"}

error: errcode: -4077

{"timestamp":"2022-09-15 00:12:27"}

error: Error: read ECONNRESET
at PromisePoolConnection.execute (E:\PJT\MLOPS\mlops_server\node_modules\mysql2\promise.js:111:22)

*And the MariaDB error log is like this: *
2022-09-15 0:08:33 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
2022-09-15 0:08:33 0 [Note] InnoDB: Number of pools: 1
2022-09-15 0:08:33 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-09-15 0:08:33 0 [Note] InnoDB: Initializing buffer pool, total size = 4294967296, chunk size = 134217728
2022-09-15 0:08:33 0 [Note] InnoDB: Completed initialization of buffer pool
2022-09-15 0:08:33 0 [Note] InnoDB: 128 rollback segments are active.
2022-09-15 0:08:33 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-09-15 0:08:33 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-09-15 0:08:33 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-09-15 0:08:33 0 [Note] InnoDB: 10.6.9 started; log sequence number 2198803090; transaction id 2871471
2022-09-15 0:08:33 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-09-15 0:08:33 0 [Note] InnoDB: Loading buffer pool(s) from C:\Program Files\MariaDB 10.6\data\ib_buffer_pool
2022-09-15 0:08:33 0 [Note] Server socket created on IP: '::'.
2022-09-15 0:08:33 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-09-15 0:08:34 0 [Note] Reading of all Master_info entries succeeded
2022-09-15 0:08:34 0 [Note] Added new Master_info '' to hash table
2022-09-15 0:08:34 0 [Note] C:\Program Files\MariaDB 10.6\bin\mysqld.exe: ready for connections.
Version: '10.6.9-MariaDB' socket: '' port: 3306 mariadb.org binary distribution
2022-09-15 0:08:34 0 [Note] InnoDB: Buffer pool(s) load completed at 220915 0:08:34
2022-09-15 0:12:07 6 [Note] Detected table cache mutex contention at instance 1: 27% waits. Additional table cache instance activated. Number of instances after activation: 2.
220915 0:12:24 [ERROR] mysqld got exception 0xc0000005 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.

To report this bug, see https://mariadb.com/kb/en/reporting-bugs

We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

Server version: 10.6.9-MariaDB
key_buffer_size=134217728
read_buffer_size=131072
max_used_connections=11
max_threads=65537
thread_count=11
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 142742882 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x1d29ed97098
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
server.dll!my_string_metadata_get()[ctype.c:910]
server.dll!Item_param::convert_str_value()[item.cc:4782]
server.dll!insert_params()[sql_prepare.cc:859]
server.dll!Prepared_statement::execute_loop()[sql_prepare.cc:4606]
server.dll!mysql_stmt_execute_common()[sql_prepare.cc:3574]
server.dll!mysqld_stmt_execute()[sql_prepare.cc:3348]
server.dll!dispatch_command()[sql_parse.cc:1828]
server.dll!do_command()[sql_parse.cc:1409]
server.dll!tp_callback()[threadpool_common.cc:203]
KERNEL32.DLL!CompareStringEx()
ntdll.dll!RtlTryEnterCriticalSection()
ntdll.dll!EtwNotificationRegister()
KERNEL32.DLL!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x0):
Connection ID (thread ID): 13
Status: NOT_KILLED

Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off

The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file at C:\Program Files\MariaDB 10.6\data\
Minidump written to C:\Program Files\MariaDB 10.6\data\mysqld.dmp

What am I supposed to do to prevent this unexpected shutdown?



 Comments   
Comment by Vladislav Vaintroub [ 2022-09-15 ]

More detailed stack trace, from the .dmp file

 	server.dll!my_string_metadata_get(MY_STRING_METADATA * metadata=0x0000007efa5ee190, const charset_info_st * cs=0x0000000000000000, const char * str=0x000001d29eddaf08, unsigned __int64 length=1) Line 910	C
 	[Inline Frame] server.dll!Item_basic_value::Metadata::{ctor}(const String *) Line 2939	C++
>	[Inline Frame] server.dll!Item_basic_value::fix_charset_and_length_from_str_value(const String &) Line 2968	C++
 	server.dll!Item_param::convert_str_value(THD * thd) Line 4782	C++
 	server.dll!insert_params(Prepared_statement * stmt=0x000001d29eea0b58, unsigned char * null_array=0x000001d29eda27b2, unsigned char * read_pos=0x000001d29eda27b6, unsigned char * data_end=0x000001d29eda2816, String * expanded_query=0x0000007efa5ee2d0) Line 859	C++
 	[Inline Frame] server.dll!Prepared_statement::set_parameters(String * packet=0x000001d29eda27b4, unsigned char *) Line 4536	C++
 	server.dll!Prepared_statement::execute_loop(String * expanded_query=0x0000007efa5ee2d0, bool open_cursor, unsigned char * packet=0x000001d29eda27b2, unsigned char * packet_end=0x000001d29eda2816) Line 4606	C++
 	server.dll!mysql_stmt_execute_common(THD * thd=0x000001d29ed97098, unsigned long stmt_id, unsigned char * packet=0x000001d29eda27b2, unsigned char * packet_end=0x000001d29eda2816, unsigned long cursor_flags=0, bool bulk_op, bool read_types=false) Line 3574	C++
 	server.dll!mysqld_stmt_execute(THD * thd, char * packet_arg, unsigned int packet_length) Line 3348	C++
 	server.dll!dispatch_command(enum_server_command command=COM_STMT_EXECUTE, THD * thd=0x000001d29ed97098, char * packet, unsigned int packet_length=109, bool blocking=false) Line 1828	C++
 	server.dll!do_command(THD * thd=0x000001d29ed97098, bool blocking) Line 1409	C++
 	[Inline Frame] server.dll!threadpool_process_request(THD *) Line 402	C++

The exception is access violation caused by deferencing NULL pointer , in ctype.c, line 910

void
my_string_metadata_get(MY_STRING_METADATA *metadata,
                       CHARSET_INFO *cs, const char *str, size_t length)
{
  if (cs->mbmaxlen == 1 && !(cs->state & MY_CS_NONASCII)) //<-- HERE cs is NULL

Unfortunately there is not much other information available from the .dmp (no heap in it only stack)

lifelix, you probably can workaround that exact bug, by avoiding prepared statements

Comment by Kyungsuk Yoo [ 2022-09-15 ]

Thanks a lot!!!
After removing all the preparedstatements, errors are gone at least for now.

By the way, how does using preparedstatement or not affect this situation?

Comment by Vladislav Vaintroub [ 2022-09-15 ]

lifelix, the crash happens in execution of prepared statement, while resolving parameters, thus my guess that it will go away once prepared statement disappear.

If you have an example of the Node.js program that used to crash, this would likely be useful here to repeat the error.

Comment by Alice Sherepa [ 2022-09-15 ]

probably the same bug as MDEV-19811

Generated at Thu Feb 08 10:09:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.