[MDEV-17260] Memory leaks in mysqlbinlog Created: 2018-09-21 Updated: 2019-04-28 Resolved: 2019-04-26 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Scripts & Clients |
| Affects Version/s: | 5.5.62, 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.2.24, 5.5.64, 10.3.15, 10.4.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Sujatha Sivakumar (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | ASAN, Memory_leak, valgrind | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
The mysqlbinlog tool is leaking memory, causing failures in various tests when compiling and testing with AddressSanitizer or LeakSanitizer like this:
|
| Comments |
| Comment by Marko Mäkelä [ 2019-01-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In 10.3, this affects the following tests: binlog_encryption.binlog_row_annotate Easy to repeat with:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-01-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
More failures in 10.2:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
One more failure, without any ASAN instrumentation:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2019-02-01 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The latest failure has been introduced by 10.2 merge of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-09 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I had a short try at fixing the leaks for
The key points of mdev-17260-wip.patch
The patch does not leak memory, but will cause output differences in 10 of the 11 tests where leaks were reported:
The following test, which previously leaked memory, does pass:
The patch also causes numerous other test failures, such as this one:
I hope that mdev-17260-wip.patch Note: While my patch is based on 10.2, I believe that the final fix should be ported to 5.5. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-09 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
While testing my patch, I found a heap-use-after-free in all 3 combinations of the test binlog.flashback. I think that that one should be fixed first, before trying to fix the output differences. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-15 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For some reason, today I was unable to repeat any LeakSanitizer warnings on 10.1 when using cmake -DWITH_ASAN=ON -DWITH_SAFEMALLOC=OFF. But I was able to repeat the leaks on 10.2. I see that I initially reported the leaks on 5.5. I do not see any related fixes to the files since then, so I would expect the leaks to remain present. Some leaks seem to be related to the flashback changes that were introduced in MariaDB 10.2.4 by | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sujatha Sivakumar (Inactive) [ 2019-04-17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
In the above report there are three different kinds of leaks were observed. In 5.5: This issue exists only in 5.5. It is specific to fake rotate events while reading binary log from a remote server. 10.2 and above: These were caused because of flashback feature and its related bug fixes. To reproduce the failures use: ASAN_OPTIONS=abort_on_error=1 ./mtr --parallel=auto binlog.binlog_row_mysqlbinlog_verbose binlog_encryption.binlog_row_annotate binlog.binlog_row_mysqlbinlog_options binlog.binlog_row_annotate encryption.tempfiles binlog.binlog_mysqlbinlog_row_myisam binlog.binlog_mysqlbinlog_row binlog.binlog_mysqlbinlog_base64 binlog_encryption.rpl_skip_replication binlog.binlog_mysqlbinlog_row_innodb binlog.flashback | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sujatha Sivakumar (Inactive) [ 2019-04-17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello Andrei, Can you please review two different patches for For 5.5: For 10.2: Thank you | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sujatha Sivakumar (Inactive) [ 2019-04-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello Andrei, Thank you for the review comments. I verified that the newly added test case fails without fix as shown below. CURRENT_TEST: binlog.flashback ================================================================= Direct leak of 48 byte(s) in 1 object(s) allocated from: SUMMARY: AddressSanitizer: 48 byte(s) leaked in 1 allocation(s). With fix it passes. http://buildbot.askmonty.org/buildbot/grid?category=main&branch=bb-10.2-sujatha Please review the new set of changes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sujatha Sivakumar (Inactive) [ 2019-04-26 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
At the time for merging 10.2 patch into 10.3 please consider the following patch. 10.3: Changes. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||