You need to sign in or sign up before continuing.
  • Marko Mäkelä's avatar
    MDEV-22271 Excessive stack memory usage due to WSREP_LOG · 7198c6ab
    Marko Mäkelä authored
    Several tests that involve stored procedures fail on 10.4 kvm-asan
    (clang 10) due to stack overrun. The main contributor to this stack
    overrun is mysql_execute_command(), which is invoked recursively
    during stored procedure execution.
    
    Rebuilding with cmake -DWITH_WSREP=OFF shrunk the stack frame size
    of mysql_execute_command() by more than 10 kilobytes in a
    WITH_ASAN=ON, CMAKE_BUILD_TYPE=Debug build. The culprit
    turned out to be the macro WSREP_LOG, which is allocating a
    separate 1KiB buffer for every occurrence.
    
    We replace the macro with a function, so that the stack will be
    allocated only when the function is actually invoked. In this way,
    no stack space will be wasted by default (when WSREP and Galera
    are disabled).
    
    This backports commit b6c5657e
    from MariaDB 10.3.1.
    
    Without ASAN, compilers can be smarter and optimize the stack usage.
    The original commit message mentions that 1KiB was saved on GCC 5.4,
    and 4KiB on Mac OS X Lion, which presumably uses a clang-based compiler.
    7198c6ab
wsrep_mysqld.h 13.3 KB