Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-38918

Starting and stopping server with --large-pages reports faux memory leak

    XMLWordPrintable

Details

    Description

      This happened for me on Windows, but it should not be restricted to Windows only. I guess large page with real large page allocations are never tested in our CI, thus nobody noticed.

      E:\10.11\xxx\sql\Debug>mysqld --large-pages --console
      2026-02-26 11:28:43 0 [Note] Starting MariaDB 10.11.16-MariaDB-debug source revision 5b4ee2840a047bc2a8db574a4eea14203e34fab3 server_uid e65T/4niuAvC0iJHjI9qAl9O+ns= as process 42380
      ....
      2026-02-26 11:28:43 0 [Note] mysqld: ready for connections.
      Version: '10.11.16-MariaDB-debug'  socket: ''  port: 3306  Source distribution
      

      Stop via Ctrl-C (on Linux you'd "kill mysqld")
      ...
      2026-02-26 11:28:45 0 [Note] console_event_handler: received CTRL_C_EVENT event
      ....
      2026-02-26 11:28:45 0 [Note] mysqld: Shutdown complete
      Warning: Memory not freed: 1048567

      The reason is incorrect size passed to my_large_free() inside ut_free_dodump(), in this stacktrace on startup

      >	server.dll!my_large_free(void * ptr, unsigned __int64 size) Line 506	C
       	server.dll!ut_free_dodump(void * ptr, unsigned __int64 size) Line 1097	C++
       	server.dll!recv_sys_t::tmp_free() Line 1476	C++
       	server.dll!recv_sys_t::debug_free() Line 1493	C++
       	server.dll!srv_start(bool create_new_db) Line 1717	C++
       	server.dll!innodb_init(void * p) Line 4225	C++
       	server.dll!ha_initialize_handlerton(void * plugin_) Line 739	C++
      
      

      The size passed is to my_large_free() is 1048585, while the actual size returned by the allocation in my_large_alloc() was 2097152 (large pages allocations are multiples of 2MB on Windows x64)
      that makes for the difference and for the faux reported "leak"

      MTR also fails like this

      ==============================================================================
       
      TEST                                      RESULT   TIME (ms) or COMMENT
      --------------------------------------------------------------------------
       
      worker[01] Using MTR_BUILD_THREAD 300, with reserved ports 19000..19029
      main.large_pages                         [ pass ]     16
      ***Warnings generated in error logs during shutdown after running tests: main.large_pages
       
      Warning: Internal memory accounting error of 1048567 bytes
       
      --------------------------------------------------------------------------
      The servers were restarted 0 times
      Spent 0.016 of 11 seconds executing testcases
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            wlad Vladislav Vaintroub
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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