[MDEV-32942] my_print_defaults leaks memory with wrong configuration file Created: 2023-12-04  Updated: 2023-12-14  Resolved: 2023-12-14

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.4
Fix Version/s: 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3

Type: Bug Priority: Minor
Reporter: Anel Husakovic Assignee: Anel Husakovic
Resolution: Fixed Votes: 0
Labels: beginner-friendly


 Description   

Build with ASAN shows memory leak when calling binary `my_print_defaults` with non-existing configuration file

$ LSAN_OPTIONS=verbosity=1:log_threads=1 ./extra/my_print_defaults '--defaults-file=~/nofile.cnf' --mysqld mysql_install_db mariadb-install-db
==60009==AddressSanitizer: libc interceptors initialized
|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||
|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||
|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||
|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||
|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||
MemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff
redzone=16
max_redzone=2048
quarantine_size_mb=256M
thread_local_quarantine_size_kb=1024K
malloc_context_size=30
SHADOW_SCALE: 3
SHADOW_GRANULARITY: 8
SHADOW_OFFSET: 0x7fff8000
==60009==Installed the sigaction for signal 11
==60009==Installed the sigaction for signal 7
==60009==Installed the sigaction for signal 8
==60009==T0: stack [0x7ffe1d2b7000,0x7ffe1dab7000) size 0x800000; local=0x7ffe1dab4534
==60009==AddressSanitizer Init done
Could not open required defaults file: /home/anel/nofile.cnf
Fatal error in defaults handling. Program aborted
==60010==Processing thread 60009.
==60010==Stack at 0x7ffe1d2b7000-0x7ffe1dab7000 (SP = 0x7ffe1dab4128).
==60010==TLS at 0x7f40721ecbc0-0x7f40721edc80.
 
=================================================================
==60009==ERROR: LeakSanitizer: detected memory leaks
 
Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7f407288a808 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
    #1 0x557a80bdc133 in my_malloc /home/anel/GitHub/mariadb/server/src/10.4/mysys/my_malloc.c:101
    #2 0x557a80bbd8cb in main /home/anel/GitHub/mariadb/server/src/10.4/extra/my_print_defaults.c:174
    #3 0x7f407221c082 in __libc_start_main ../csu/libc-start.c:308
    #4 0x557a80bbd20d in _start (/home/anel/GitHub/mariadb/server/build/10.4/extra/my_print_defaults+0x7420d)
 
SUMMARY: AddressSanitizer: 120 byte(s) leaked in 1 allocation(s).
Aborted (core dumped)



 Comments   
Comment by Sisi Huang [ 2023-12-10 ]

Hi, I would like to work on this issue

Comment by Anel Husakovic [ 2023-12-10 ]

Great, feel free to take it.

Comment by Sisi Huang [ 2023-12-10 ]

https://github.com/MariaDB/server/pull/2912

Comment by Daniel Black [ 2023-12-14 ]

Thank you hsser

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