MDEV-39831 mtr to handle LSAN_OPTIONS better#5168
Conversation
Its useful to add own LSAN_OPTIONS like report_objects=1 so lets make sure MTR doesn't overwrite this.
When we have a rr recording of the process, a memory location
is a useful thing to have in the err log of leaks.
The output comes out like:
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x55b08dbccdb8 in malloc (/build/sql/mariadbd+0x1b89db8) (BuildId: 4d72569bed63ce1fbf55d51e4d4a84b610efd87d)
#1 0x7b3fe387a1b1 (<unknown module>)
#2 0x7b3fe37c492f (<unknown module>)
#3 0x7b3fe3058407 (<unknown module>)
#4 0x7b3fe2f09493 (<unknown module>)
Objects leaked above:
0x7b7feafe0990 (40 bytes)
Now once the location is resolved we can check that we resolving the
right object leak.
There was a problem hiding this comment.
Code Review
This pull request updates the test suite configuration to preserve existing LSAN_OPTIONS environment variables when setting new options. However, the current implementation can append a trailing colon when LSAN_OPTIONS is empty or undefined, which may trigger syntax warnings from LSAN/ASAN and cause test failures. Additionally, a missing semicolon in mysql-test/lib/My/Debugger.pm should be fixed to ensure valid Perl syntax.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| push @::global_suppressions, qr/InnoDB: native AIO failed/; | ||
| ::mtr_error('rr requires kernel.perf_event_paranoid <= 1') | ||
| if ::mtr_grab_file('/proc/sys/kernel/perf_event_paranoid') > 1; | ||
| $ENV{LSAN_OPTIONS}= "report_objects=1:" . ($ENV{LSAN_OPTIONS} || '') |
There was a problem hiding this comment.
Appending a trailing colon when $ENV{LSAN_OPTIONS} is empty or undefined can lead to syntax warnings from LSAN/ASAN (e.g., complaining about empty options or missing =). Since mtr is highly sensitive to unexpected output on stderr, these warnings can cause test failures. Additionally, a terminating semicolon should be added to ensure robust Perl syntax.
We can conditionally append the colon only when $ENV{LSAN_OPTIONS} is non-empty.
$ENV{LSAN_OPTIONS}= "report_objects=1" . ($ENV{LSAN_OPTIONS} ? ":$ENV{LSAN_OPTIONS}" : "");
| $ENV{LSAN_OPTIONS}= "suppressions=${glob_mysql_test_dir}/lsan.supp:print_suppressions=0:" | ||
| . ($ENV{LSAN_OPTIONS} || '') |
There was a problem hiding this comment.
Appending a trailing colon when $ENV{LSAN_OPTIONS} is empty or undefined can lead to syntax warnings from LSAN/ASAN. We should conditionally append the colon only when $ENV{LSAN_OPTIONS} is non-empty.
$ENV{LSAN_OPTIONS}= "suppressions=${glob_mysql_test_dir}/lsan.supp:print_suppressions=0"
. ($ENV{LSAN_OPTIONS} ? ":$ENV{LSAN_OPTIONS}" : "")
extend, rather than overwrite LSAN_OPTIONS.
report_objects when recording under rr. Only has an effect if ASAN is there.