Details

    Description

      The mysqlbinlog tool is leaking memory, causing failures in various tests when compiling and testing with AddressSanitizer or LeakSanitizer like this:

      cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN:BOOL=ON /path/to/source
      make -j$(nproc)
      cd mysql-test
      ASAN_OPTIONS=abort_on_error=1 ./mtr --parallel=auto
      

      5.5 e07118946a82af60c7cc3804c321d3fd9a49f128

      CURRENT_TEST: rpl.rpl_row_mysqlbinlog
       
      =================================================================
      ==8988==ERROR: LeakSanitizer: detected memory leaks
       
      Direct leak of 112 byte(s) in 1 object(s) allocated from:
          #0 0x4eff87 in __interceptor_malloc (/dev/shm/5.5/client/mysqlbinlog+0x4eff87)
          #1 0x60eaab in my_malloc /mariadb/5.5/mysys/my_malloc.c:41:10
          #2 0x5300dd in Log_event::read_log_event(char const*, unsigned int, char const**, Format_description_log_event const*, char) /mariadb/5.5/sql/log_event.cc:1568:12
          #3 0x564a9c in dump_remote_log_entries(st_print_event_info*, char const*) /mariadb/5.5/client/mysqlbinlog.cc:1978:17
          #4 0x536408 in dump_log_entries(char const*) /mariadb/5.5/client/mysqlbinlog.cc:1794:21
          #5 0x535e4b in main /mariadb/5.5/client/mysqlbinlog.cc:2505:18
          #6 0x7f71ea0a1b16 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x22b16)
      

      Attachments

        Issue Links

          Activity

            In the above report there are three different kinds of leaks were observed.

            In 5.5:
            =====
            CURRENT_TEST: rpl.rpl_row_mysqlbinlog
            ================================================================
            ==8988==ERROR: LeakSanitizer: detected memory leaks
            Direct leak of 112 byte(s) in 1 object(s) allocated from:
            #0 0x4eff87 in __interceptor_malloc (/dev/shm/5.5/client/mysqlbinlog+0x4eff87)
            #1 0x60eaab in my_malloc /mariadb/5.5/mysys/my_malloc.c:41:10
            #2 0x5300dd in Log_event::read_log_event(char const*, unsigned int, char const*, Format_description_log_event const, char) /mariadb/5.5/sql/log_event.cc:1568:12
            #3 0x564a9c in dump_remote_log_entries(st_print_event_info*, char const*) /mariadb/5.5/client/mysqlbinlog.cc:1978:17
            #4 0x536408 in dump_log_entries(char const*) /mariadb/5.5/client/mysqlbinlog.cc:1794:21
            #5 0x535e4b in main /mariadb/5.5/client/mysqlbinlog.cc:2505:18
            #6 0x7f71ea0a1b16 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x22b16)

            This issue exists only in 5.5. It is specific to fake rotate events while reading binary log from a remote server.
            This issues is already fixed in MariaDB 10.0.23 and higher versions as part of
            commit c3018b0ff4fb02c029787d03867adf0530607bab

            10.2 and above:
            =============
            1) Leak in Log_event::read_log_event(char const*, unsigned int, char const**,
            Format_description_log_event const*, char)
            File: sql/log_event.cc:2150
            2) read_remote_annotate_event(unsigned char*, unsigned long, char const**)
            File: client/mysqlbinlog.cc:194

            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

            sujatha.sivakumar Sujatha Sivakumar (Inactive) added a comment - In the above report there are three different kinds of leaks were observed. In 5.5: ===== CURRENT_TEST: rpl.rpl_row_mysqlbinlog ================================================================ ==8988==ERROR: LeakSanitizer: detected memory leaks Direct leak of 112 byte(s) in 1 object(s) allocated from: #0 0x4eff87 in __interceptor_malloc (/dev/shm/5.5/client/mysqlbinlog+0x4eff87) #1 0x60eaab in my_malloc /mariadb/5.5/mysys/my_malloc.c:41:10 #2 0x5300dd in Log_event::read_log_event(char const*, unsigned int, char const* , Format_description_log_event const , char) /mariadb/5.5/sql/log_event.cc:1568:12 #3 0x564a9c in dump_remote_log_entries(st_print_event_info*, char const*) /mariadb/5.5/client/mysqlbinlog.cc:1978:17 #4 0x536408 in dump_log_entries(char const*) /mariadb/5.5/client/mysqlbinlog.cc:1794:21 #5 0x535e4b in main /mariadb/5.5/client/mysqlbinlog.cc:2505:18 #6 0x7f71ea0a1b16 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x22b16) This issue exists only in 5.5. It is specific to fake rotate events while reading binary log from a remote server. This issues is already fixed in MariaDB 10.0.23 and higher versions as part of commit c3018b0ff4fb02c029787d03867adf0530607bab 10.2 and above: ============= 1) Leak in Log_event::read_log_event(char const*, unsigned int, char const**, Format_description_log_event const*, char) File: sql/log_event.cc:2150 2) read_remote_annotate_event(unsigned char*, unsigned long, char const**) File: client/mysqlbinlog.cc:194 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
            sujatha.sivakumar Sujatha Sivakumar (Inactive) added a comment - Hello Andrei, Can you please review two different patches for MDEV-17260 fix. For 5.5: ====== http://buildbot.askmonty.org/buildbot/grid?category=main&branch=bb-5.5-sujatha https://github.com/MariaDB/server/commit/8b066a3d234e17249ca638a76cdd48a279633d34 For 10.2: ======= http://buildbot.askmonty.org/buildbot/grid?category=main&branch=bb-10.2-sujatha https://github.com/MariaDB/server/commit/fdf298c036fa0bb68fe3e2f0bfd28bf3b3f466d1 Thank you

            Hello Andrei,

            Thank you for the review comments.
            I have added a test case which covers flashback and remote options.

            I verified that the newly added test case fails without fix as shown below.

            CURRENT_TEST: binlog.flashback

            =================================================================
            ==26328==ERROR: LeakSanitizer: detected memory leaks

            Direct leak of 48 byte(s) in 1 object(s) allocated from:
            #0 0x7f496b046b50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50)
            #1 0x55a508dd102b in my_malloc /home/sujatha/bug_repo/MDEV-17260-10.2/mysys/my_malloc.c:101
            #2 0x55a508c8d57e in read_remote_annotate_event(unsigned char*, unsigned long, char const**) /home/sujatha/bug_repo/MDEV-17260-10.2/client/mysqlbinlog.cc:194
            #3 0x55a508c93c69 in handle_event_text_mode /home/sujatha/bug_repo/MDEV-17260-10.2/client/mysqlbinlog.cc:2285
            #4 0x55a508c95fcf in dump_remote_log_entries /home/sujatha/bug_repo/MDEV-17260-10.2/client/mysqlbinlog.cc:2608
            #5 0x55a508c9351b in dump_log_entries /home/sujatha/bug_repo/MDEV-17260-10.2/client/mysqlbinlog.cc:2162
            #6 0x55a508c97b5b in main /home/sujatha/bug_repo/MDEV-17260-10.2/client/mysqlbinlog.cc:3098
            #7 0x7f49698b4b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)

            SUMMARY: AddressSanitizer: 48 byte(s) leaked in 1 allocation(s).
            Aborted (core dumped)
            mysqltest: At line 355: exec of '/home/sujatha/bug_repo/MDEV-17260-10.2/bld/client/mysqlbinlog --defaults-file=/home/sujatha/bug_repo/MDEV-17260-10.2/bld/mysql-test/var/2/my.cnf --local-load=/home/sujatha/bug_repo/MDEV-17260-10.2/bld/mysql-test/var/tmp/2 -vv -B --read-from-remote-server --user=root --host=127.0.0.1 --port=16020 master-bin.000002> /home/sujatha/bug_repo/MDEV-17260-10.2/bld/mysql-test/var/2/tmp/mysqlbinlog_row_flashback_4.sql' failed, error: 34304, status: 134, errno: 11
            Output from before failure:
            f

            With fix it passes.

            http://buildbot.askmonty.org/buildbot/grid?category=main&branch=bb-10.2-sujatha
            https://github.com/MariaDB/server/commit/8ae7a5eb03725441393c353e4e203f80b666c035

            Please review the new set of changes.

            sujatha.sivakumar Sujatha Sivakumar (Inactive) added a comment - Hello Andrei, Thank you for the review comments. I have added a test case which covers flashback and remote options. I verified that the newly added test case fails without fix as shown below. CURRENT_TEST: binlog.flashback ================================================================= ==26328==ERROR: LeakSanitizer: detected memory leaks Direct leak of 48 byte(s) in 1 object(s) allocated from: #0 0x7f496b046b50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50) #1 0x55a508dd102b in my_malloc /home/sujatha/bug_repo/ MDEV-17260 -10.2/mysys/my_malloc.c:101 #2 0x55a508c8d57e in read_remote_annotate_event(unsigned char*, unsigned long, char const**) /home/sujatha/bug_repo/ MDEV-17260 -10.2/client/mysqlbinlog.cc:194 #3 0x55a508c93c69 in handle_event_text_mode /home/sujatha/bug_repo/ MDEV-17260 -10.2/client/mysqlbinlog.cc:2285 #4 0x55a508c95fcf in dump_remote_log_entries /home/sujatha/bug_repo/ MDEV-17260 -10.2/client/mysqlbinlog.cc:2608 #5 0x55a508c9351b in dump_log_entries /home/sujatha/bug_repo/ MDEV-17260 -10.2/client/mysqlbinlog.cc:2162 #6 0x55a508c97b5b in main /home/sujatha/bug_repo/ MDEV-17260 -10.2/client/mysqlbinlog.cc:3098 #7 0x7f49698b4b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96) SUMMARY: AddressSanitizer: 48 byte(s) leaked in 1 allocation(s). Aborted (core dumped) mysqltest: At line 355: exec of '/home/sujatha/bug_repo/ MDEV-17260 -10.2/bld/client/mysqlbinlog --defaults-file=/home/sujatha/bug_repo/ MDEV-17260 -10.2/bld/mysql-test/var/2/my.cnf --local-load=/home/sujatha/bug_repo/ MDEV-17260 -10.2/bld/mysql-test/var/tmp/2 -vv -B --read-from-remote-server --user=root --host=127.0.0.1 --port=16020 master-bin.000002> /home/sujatha/bug_repo/ MDEV-17260 -10.2/bld/mysql-test/var/2/tmp/mysqlbinlog_row_flashback_4.sql' failed, error: 34304, status: 134, errno: 11 Output from before failure: f With fix it passes. http://buildbot.askmonty.org/buildbot/grid?category=main&branch=bb-10.2-sujatha https://github.com/MariaDB/server/commit/8ae7a5eb03725441393c353e4e203f80b666c035 Please review the new set of changes.

            At the time for merging 10.2 patch into 10.3 please consider the following patch.

            10.3: Changes.
            https://github.com/MariaDB/server/commit/ddfd6297f8f7cf2009d326ae825c75c918fe8ef3

            sujatha.sivakumar Sujatha Sivakumar (Inactive) added a comment - At the time for merging 10.2 patch into 10.3 please consider the following patch. 10.3: Changes. https://github.com/MariaDB/server/commit/ddfd6297f8f7cf2009d326ae825c75c918fe8ef3
            marko Marko Mäkelä added a comment - Merged to 10.3

            People

              sujatha.sivakumar Sujatha Sivakumar (Inactive)
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.