Skip to content

MDEV-38838 Memory loss in CONNECT from handler::ha_rnd_init#5050

Open
grooverdan wants to merge 3 commits into
MariaDB:10.11from
grooverdan:MDEV-38838
Open

MDEV-38838 Memory loss in CONNECT from handler::ha_rnd_init#5050
grooverdan wants to merge 3 commits into
MariaDB:10.11from
grooverdan:MDEV-38838

Conversation

@grooverdan
Copy link
Copy Markdown
Member

This was a leak in unixODBC 2.3.14 where a cache was allocated but not returned. The LD_PRELOAD is so the resolution will be aware of the resolution for save_ini_cache that caused the leak.

@grooverdan grooverdan added the MariaDB Foundation Pull requests created by MariaDB Foundation label May 7, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a leak suppression for unixODBC in the LSAN configuration and introduces logic to LD_PRELOAD the ODBC library within the test suite to ensure proper address resolution. Feedback focuses on improving the portability of the hardcoded library path, refining the LD_PRELOAD environment variable assignment to avoid leading colons, and correcting a typo in the documentation.

Comment thread storage/connect/mysql-test/connect/suite.pm
@grooverdan grooverdan force-pushed the MDEV-38838 branch 3 times, most recently from 26f81bc to dc53089 Compare May 8, 2026 03:30
@grooverdan grooverdan requested a review from vuvova May 8, 2026 04:14
@grooverdan grooverdan changed the title Memory loss in CONNECT from handler::ha_rnd_init MDEV-38838 Memory loss in CONNECT from handler::ha_rnd_init May 8, 2026
This was a leak in <=unixODBC 2.3.15 where a cache was allocated
but not returned. Using the suite.pm for the connect engine
we see if the connect engine is compiled with ASAN (that includes
LeakSanitizer) and we check the unixODBC version to see if it is
a version (currently unreleased) that has a inst_logClose symbol
which is part of the unixODBC leak fix. If it is not a leak fixed
version, a LD_PRELOAD of the unixODBC library occurs so that the
LeakSanitizer suppression can resolve the save_ini_cache entry.

Alterates considered:
1. __clear_ini_cache in libodbcinst (2.3.12+) is an interface,
for which there is no header define. A CMake would need to
do full compile and link to check its existance. Workable,
just wanted a simplier solution. It looked like it shoud be a
better interface in unixODBC.

2. could skip asan tests on CONNECT/ODBC, but this is skipping
coverage we want.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

MariaDB Foundation Pull requests created by MariaDB Foundation

Development

Successfully merging this pull request may close these issues.

2 participants