[MDEV-26330] --max-session-mem-used=8192 leads to 280 bytes lost and "max-**thread**-mem-used" related error and SIGSEGV in my_malloc_size_cb_func Created: 2021-08-10  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: Memory_leak, regression-10.6


 Description   

--max-session-mem-used=8192

Passed as a startup parameter will result in:

10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Debug)

2021-08-10 14:16:13 0 [Note] InnoDB: 10.7.0 started; log sequence number 33634; transaction id 4
2021-08-10 14:16:13 0 [Note] InnoDB: Loading buffer pool(s) from /test/MD200721-mariadb-10.7.0-linux-x86_64-dbg/data/ib_buffer_pool
2021-08-10 14:16:13 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-08-10 14:16:13 0 [ERROR] Could not open mysql.plugin table: "The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement". Some plugins may be not loaded
2021-08-10 14:16:13 0 [Note] InnoDB: Buffer pool(s) load completed at 210810 14:16:13
2021-08-10 14:16:13 0 [ERROR] Can't open and lock privilege tables: The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement
2021-08-10 14:16:13 0 [Note] Server socket created on IP: '0.0.0.0'.
2021-08-10 14:16:13 0 [Note] Server socket created on IP: '::'.
2021-08-10 14:16:13 0 [ERROR] Fatal error: Can't open and lock privilege tables: The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement
2021-08-10 14:16:13 0 [ERROR] Aborting
Warning: Memory not freed: 280
Warning:  280 bytes lost at 0x5606a3ae8370, allocated by T@0 at 0x5606a12359c6, mysys/my_malloc.c:141, mysys/array.c:151, mysys/array.c:95, sql/mysqld.cc:2244, sql/mysqld.cc:2534, csu/libc-start.c:342, ??:0
Memory lost: 280 bytes in 1 chunks

10.7.0 71ed8c136fa203b9b3a678a6d5cc72235ef73ef7 (Optimized)

2021-08-10 14:37:13 0 [Note] InnoDB: 10.7.0 started; log sequence number 33050; transaction id 4
2021-08-10 14:37:13 0 [Note] InnoDB: Loading buffer pool(s) from /test/MD200721-mariadb-10.7.0-linux-x86_64-opt/data/ib_buffer_pool
2021-08-10 14:37:13 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-08-10 14:37:13 0 [ERROR] Could not open mysql.plugin table: "The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement". Some plugins may be not loaded
2021-08-10 14:37:13 0 [Note] InnoDB: Buffer pool(s) load completed at 210810 14:37:13
2021-08-10 14:37:13 0 [ERROR] Can't open and lock privilege tables: The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement
2021-08-10 14:37:13 0 [Note] Server socket created on IP: '0.0.0.0'.
2021-08-10 14:37:13 0 [Note] Server socket created on IP: '::'.
2021-08-10 14:37:13 0 [ERROR] Fatal error: Can't open and lock privilege tables: The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement
2021-08-10 14:37:13 0 [ERROR] Aborting
Warning: Memory not freed: 280

10.6.4 42b9daaea7ece6155558f7c3bf638e8e175a7ff7 (Optimized)

Core was generated by `/test/MD260721-mariadb-10.6.4-linux-x86_64-opt/bin/mariadbd --no-defaults --lc-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000556304bf6f48 in my_malloc_size_cb_func (size=<optimized out>, 
    is_thread_specific=<optimized out>) at /test/10.6_opt/sql/mysqld.cc:3641
[Current thread is 1 (Thread 0x153d53256800 (LWP 4071519))]
(gdb) bt
#0  0x0000556304bf6f48 in my_malloc_size_cb_func (size=<optimized out>, is_thread_specific=<optimized out>) at /test/10.6_opt/sql/mysqld.cc:3641
#1  0x000055630546bbce in my_malloc (key=0, size=<optimized out>, size@entry=1048, my_flags=my_flags@entry=65536) at /test/10.6_opt/mysys/my_malloc.c:108
#2  0x000055630546398a in init_alloc_root (key=key@entry=0, mem_root=mem_root@entry=0x556306c1be40, block_size=block_size@entry=2048, pre_alloc_size=pre_alloc_size@entry=1024, my_flags=my_flags@entry=65536) at /test/10.6_opt/mysys/my_alloc.c:80
#3  0x0000556304db79d9 in init_sql_alloc (key=key@entry=0, mem_root=mem_root@entry=0x556306c1be40, block_size=block_size@entry=2048, pre_alloc=pre_alloc@entry=1024, my_flags=my_flags@entry=65536) at /test/10.6_opt/sql/thr_malloc.cc:64
#4  0x0000556304c8c45a in Warning_info::init (this=this@entry=0x556306c1be40) at /test/10.6_opt/sql/sql_error.cc:520
#5  0x0000556304c7fe33 in Diagnostics_area::init (this=0x556306c1bc00) at /test/10.6_opt/sql/sql_error.h:1091
#6  THD::THD (this=0x556306c15f38, id=<optimized out>, is_wsrep_applier=<optimized out>) at /test/10.6_opt/sql/sql_class.cc:740
#7  0x0000556304c807bd in create_background_thd () at /test/10.6_opt/sql/sql_list.h:680
#8  0x0000556305209c94 in innobase_create_background_thd (name=name@entry=0x5563057adf0f "InnoDB FTS optimizer") at /test/10.6_opt/storage/innobase/handler/ha_innodb.cc:1777
#9  0x00005563053d3bf5 in fts_optimize_init () at /test/10.6_opt/storage/innobase/fts/fts0opt.cc:2938
#10 0x0000556304b98551 in srv_start (create_new_db=<optimized out>) at /test/10.6_opt/storage/innobase/srv/srv0start.cc:1810
#11 0x0000556305219b12 in innodb_init (p=<optimized out>) at /test/10.6_opt/storage/innobase/handler/ha_innodb.cc:4156
#12 0x0000556304f026b2 in ha_initialize_handlerton (plugin=0x5563067df7e0) at /test/10.6_opt/sql/handler.cc:659
#13 0x0000556304cdeb18 in plugin_initialize (tmp_root=<optimized out>, plugin=0x5563067df7e0, argc=0x556305df7f20 <remaining_argc>, argv=<optimized out>, options_only=<optimized out>) at /test/10.6_opt/sql/sql_plugin.cc:1463
#14 0x0000556304cdfccb in plugin_init (argc=argc@entry=0x556305df7f20 <remaining_argc>, argv=<optimized out>, flags=1) at /test/10.6_opt/sql/sql_plugin.cc:1756
#15 0x0000556304bf9ae2 in init_server_components () at /test/10.6_opt/sql/mysqld.cc:5041
#16 0x0000556304bff4ab in mysqld_main (argc=<optimized out>, argv=<optimized out>) at /test/10.6_opt/sql/mysqld.cc:5653
#17 0x0000153d534140b3 in __libc_start_main (main=0x556304bc42d0 <main(int, char**)>, argc=13, argv=0x7ffc70463d48, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffc70463d38) at ../csu/libc-start.c:308
#18 0x0000556304bf447e in _start () at /test/10.6_opt/sql/mysqld.cc:4473

10.6.4 42b9daaea7ece6155558f7c3bf638e8e175a7ff7 (Debug)

2021-08-10 14:41:13 0 [Note] InnoDB: 10.6.4 started; log sequence number 33622; transaction id 4
2021-08-10 14:41:13 0 [Note] InnoDB: Loading buffer pool(s) from /test/MD260721-mariadb-10.6.4-linux-x86_64-dbg/data/ib_buffer_pool
2021-08-10 14:41:13 0 [Note] Plugin 'FEEDBACK' is disabled.
2021-08-10 14:41:13 0 [ERROR] Could not open mysql.plugin table: "The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement". Some plugins may be not loaded
2021-08-10 14:41:13 0 [Note] InnoDB: Buffer pool(s) load completed at 210810 14:41:13
2021-08-10 14:41:13 0 [ERROR] Can't open and lock privilege tables: The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement
2021-08-10 14:41:13 0 [Note] Server socket created on IP: '0.0.0.0'.
2021-08-10 14:41:13 0 [Note] Server socket created on IP: '::'.
2021-08-10 14:41:13 0 [ERROR] Fatal error: Can't open and lock privilege tables: The MariaDB server is running with the --max-thread-mem-used=8192 option so it cannot execute this statement
2021-08-10 14:41:13 0 [ERROR] Aborting
Warning: Memory not freed: 280
Warning:  280 bytes lost at 0x56458386a580, allocated by T@0 at mysys/my_malloc.c:141, mysys/array.c:151, mysys/array.c:95, sql/mysqld.cc:2241, sql/mysqld.cc:2531, sql/main.cc:36, csu/libc-start.c:342, ??:0
Memory lost: 280 bytes in 1 chunks

Besides the 280 bytes lost and SIGSEGV, note that the message states "max-thread-mem-used" whereas the option passed is "max-session-mem-used".

The memory error does not show on 10.2-10.5, so something must have changed between 10.5 and 10.6 (regression).

10.2 to 10.5 optimized builds do crash.


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