[MDEV-31566] All kinds of crash with RtlFreeHeap() Created: 2023-06-28 Updated: 2024-02-08 |
|
| Status: | In Review |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.4.30 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0 |
| Type: | Bug | Priority: | Critical |
| Reporter: | george he | Assignee: | Rucha Deodhar |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | crash | ||
| Environment: |
Windows Server 2008R2, Linux |
||
| Description |
|
The server often crashes.
|
| Comments |
| Comment by Marko Mäkelä [ 2023-06-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
All stack traces are for cases when some dynamically allocated heap memory is being freed. I suspect that the internal memory structures that ucrtbase.DLL or ntdll.dll uses for implementing primitives like malloc() and free() have been corrupted by a buffer overrun or a write through an invalid pointer. There are some open bugs mentioning AddressSanitizer diagnostics heap-use-after-free, heap-use-after-poison, heap-buffer-overflow. I am not familiar with the debugging tools on Microsoft Windows, but I would expect there to be some debug version of the runtime library, which would help catch the actual culprit of the corruption, instead of seeing a crash in unrelated code later. As always, an SQL test case for reproducing these failures would be helpful. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by george he [ 2023-06-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for your reply! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-06-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
MariaDB supports Windows version in their active lifecycle (until the product reaches the Mainstream Support End Date). Unfortunately, Windows Server 2008R2 is far beyond that date. Is there any specific reason for using such an outdated version of the OS? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by george he [ 2023-06-28 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Not upgraded just because I don't have the time, as it's a production server. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2023-06-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I do not think debug compilation by itself is going to reveal much. There are 2 options that can be more useful gflags /p /enable mysqld.exe /full execute the above in the elevated command line to enable pageheap on the mysqld, and restart the server. The effect is that program will crash when trying to access unallocated region, making culprit more obvious when finished, execute 2. Address sanitizer compilation (works with relatively new VS2022) If you run it on a different machine then the one you compiled on, you'd need to copy Don't use 1. and 2. at the same time, it would not work. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by george he [ 2023-06-29 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank Vladislav Vaintroub! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by george he [ 2023-07-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Finally the reproducing sql is found. The following sql would always crash the server:
Could someone have a look at it? Thanks! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleg Smirnov [ 2023-07-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Can you attach the error call stack? I could not reproduce this on my Windows 10 machine with MariaDB 10.4.30. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2023-07-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Got this stack in ASAN build ( heap buffer overflow) trying to execute the query by reporter. select column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E); Mostly likely, the bug is portable , i.e can be reproduced outside of Windows, although I did not try
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Vladislav Vaintroub [ 2023-07-05 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
yes, same thing with Linux/ASAN, trying select column_json(0x0402000A0000000300030023076A736E7375626A6563742E0005006C0027000200290002002B0002002D0002002F0002000C31000C3B000C4B000C51000F62006631663266336634663509E5A79AE8BF9CE6B48B0FE8819AE9809AE98791E6A1A5E5BA970537343530301031313634332F393634352F31313630300C080000000000EFBFBDEFBFBD192E) crashes on the same line
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by george he [ 2023-11-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
How is this going on? The server crashes now and then. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by george he [ 2023-12-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Finally I find the bug is buffer overrun, and initiate the pull request #2892 to fix it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2024-02-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
crashing bug, ready to review. |