[MDEV-22271] Excessive stack memory usage due to WSREP_LOG Created: 2020-04-17 Updated: 2020-04-27 Resolved: 2020-04-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Stored routines, wsrep |
| Affects Version/s: | 10.1, 10.3.0, 10.4.2, 10.2, 10.5 |
| Fix Version/s: | 10.3.1, 10.1.45, 10.2.32, 10.4.13, 10.5.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | regression | ||
| Description |
|
Several tests fail on 10.4 kvm-asan due to stack overrun:
The main contributor to this stack overrun is mysql_execute_command(). Rebuilding with cmake -DWITH_WSREP=OFF shrunk the size of the mysql_execute_command() stack frame in the ASAN debug build from 29312 to 17568 bytes. A quick and dirty workaround made the tests pass:
It turns out that this bug had been fixed in MariaDB 10.3.1 but the fix was destroyed in the Galera 4 merge ( This bug should affect all builds, especially affecting the execution of complex stored procedures, which involves recursive calls to mysql_execute_command(). The WSREP_DEBUG macro invocations will expand to WSREP_LOG also in non-debug builds, and obviously, the stack memory will be allocated even with the default settings (WSREP or Galera are disabled). |
| Comments |
| Comment by Marko Mäkelä [ 2020-04-17 ] |
|
Without ASAN, compilers can be smarter and optimize the stack usage. The original commit message for MariaDB 10.3.1 mentioned that 1KiB was saved on GCC 5.4, and 4KiB on Mac OS X Lion, which presumably uses a clang-based compiler. |