[MDEV-16660] Inadequate DEFAULT_THREAD_STACK size for AddressSanitizer Created: 2018-07-02 Updated: 2024-01-10 Resolved: 2023-11-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Compiling, Parser |
| Affects Version/s: | 10.3 |
| Fix Version/s: | 10.4.33, 10.5.24, 10.6.17, 10.11.7, 11.0.5, 11.1.4, 11.2.3, 11.3.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | ASAN | ||
| Issue Links: |
|
||||||||
| Description |
|
When the code is compiled with Clang 6.0.3 and cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN:BOOL=ON, 3 of these 4 tests will cause a server crash instead of reporting a stack overflow error. If -O1 is added to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS, then these tests will pass:
|
| Comments |
| Comment by Marko Mäkelä [ 2023-11-17 ] | ||||||||||||||||||||||||||||||||
|
By design, AddressSanitizer will allocate some "sentinel" areas in stack frames so that it can better catch buffer overflows, by trapping access to memory addresses that reside between stack-allocated variables. Apparently, something has been changed in recent compilers, and I am seeing a need for a larger thread stack size when using -DWITH_ASAN=ON with GCC 12.3.0, GCC 13.2.0, or clang 16.0.6. The minimum stack size to pass bootstrap is smaller for non-debug builds, and smaller for GCC 12 than for GCC 13. Here is an example from clang 16.0.6, CMAKE_BUILD_TYPE=RelWithDebInfo and WITH_ASAN=ON:
I don’t think that this is a bug in our actual code or the stack overflow detection, just an issue with the build parameters. The following patch fixes this for me:
I think that to be on the safe side, we’d better use 10 MiB instead of the above 9 MiB. That is what I have been using in my local builds recently. Apparently, on our CI systems, the compilers used for ASAN builds are older, because the problem has not occurred there. | ||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-11-30 ] | ||||||||||||||||||||||||||||||||
|
On 10.5 and GCC 13.2.0 we seem to need 11 MiB of thread stack; 10 MiB is not enough:
|