Commit 4980fcb
committed
MDEV-33867 main.query_cache_debug fails with heap-use-after-free
What's happening: 1. Query_cache::insert() locks the QC and verifies that it's enabled 2. parallel thread tries to disable it. trylock fails (QC is locked) so the status becomes DISABLE_REQUEST 3. Query_cache::insert() calls Query_cache::write_result_data() which allocates a new block and unlocks the QC. 4. Query_cache::unlock() notices there are no more QC users and a pending DISABLE_REQUEST so it disables the QC and frees all the memory, including the new block that was just allocated 5. Query_cache::write_result_data() proceeds to write into the freed block Fix: change m_cache_status under a mutex. Approved by Oleksandr Byelkin <sanja@mariadb.com>1 parent d4936c8 commit 4980fcb
1 file changed
+2
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2530 | 2530 | | |
2531 | 2531 | | |
2532 | 2532 | | |
| 2533 | + | |
2533 | 2534 | | |
2534 | | - | |
2535 | | - | |
2536 | | - | |
2537 | | - | |
2538 | | - | |
2539 | | - | |
2540 | | - | |
| 2535 | + | |
2541 | 2536 | | |
2542 | 2537 | | |
2543 | 2538 | | |
| |||
0 commit comments