Rex Johnston
007b40adaf
MDEV-40012 PQ: end a worker's parallel scan before close() frees m_prebuilt
...
A worker's handler was destroyed with its parallel scan still open.
exec() and scan_only() jump to their exit labels when
parallel_init_worker() fails, and the commonest failure is
HA_ERR_END_OF_FILE: no chunk was left for this worker, which happens all
the time on small tables. InnoDB has allocated m_pscan_worker by then, so
the scan was left for ~ha_innobase() -> parallel_scan_free(), which runs
after close() has freed m_prebuilt. parallel_scan_free() says it drops the
worker without end() for exactly that reason, but ~Parallel_scan_worker()
called end() anyway, and end() writes m_prebuilt->pscan_chunk_clamp: a
heap-use-after-free that ASAN reports on every such worker. In a build
without ASAN the write lands in freed memory, and it is the likely cause of
the intermittent SIGSEGV in free() inside pthread_create() when a later
worker reused a cached thread stack whose DTV had been overwritten.
Three changes close it. Both workers now end the scan at their exit label
instead of after the loop, so every way out ends it while the handler is
still open; ending a scan that was never begun is harmless.
ha_innobase::close() ends any worker or coordinator scan still open before
row_prebuilt_free(), so a path that misses it is ended properly rather than
left for the destructor; with the SQL layer put back as it was, this alone
keeps ASAN clean. And ~Parallel_scan_worker() no longer calls end(), so
parallel_scan_free(), now reached only for a handler destroyed without
close(), cannot write through m_prebuilt either. The close() hook and the
single call site are taken from a patch by a co-worker.
Two debug assertions state the rule the defect broke, so it no longer
takes ASAN to see it. ha_innobase::close() asserts that the SQL layer has
already ended a worker's scan, and parallel_scan_free() asserts that no
worker survives close(). The injection pwt_leave_scan_for_close makes the
SQL layer leave the scan of a worker that holds no cursor -- one handed no
chunk -- for close() to end, so the backstop is exercised on purpose and
the first assertion is told to allow it. pwt_end_worker_scan() holds the
injection and ends the scan at both exit labels.
parallel_query_no_chunk (debug only) runs a full scan and a range scan of a
one-page table with four workers, so three of them get no chunk, twice
each, through the normal and the scan-only path, with and without the
injection, checking the rows and that the workers ran every query. In a
plain debug build, removing the exit-label calls fails the first assertion
and removing the close() backstop fails the second.
~Parallel_scan_worker() no longer calling end() is defence for release
builds and is not reachable while the backstop is there.
This commit was prepared with Claude Code (Opus 5.5), which reproduced the
pthread_create() crash under ASAN and traced it, wrote the fix, folded in
the co-worker's close() hook and single call site, added the debug
assertions, the injection and the test, confirmed in a plain debug build
that the test fails with each of the two fixes removed, and ran the
parallel_query tests in normal and --ps-protocol modes and the main suite
with --parallel-worker-threads=4 under ASAN.
2026-10-20 08:31:36 +13:00
..
2026-08-13 23:15:53 +04:00
2026-06-15 16:53:03 +02:00
2026-05-26 20:00:43 +04:00
2025-06-13 08:52:54 +10:00
2026-08-13 23:15:53 +04:00
2026-06-17 16:46:39 +02:00
2026-09-07 14:08:34 +12:00
2024-05-27 12:39:02 +02:00
2024-05-27 12:39:02 +02:00
2026-05-15 13:30:21 +10:00
2026-08-03 13:42:39 +02:00
2026-02-06 17:46:52 +01:00
2024-11-05 14:00:47 -08:00
2025-07-28 21:29:29 +02:00
2024-11-05 14:00:48 -08:00
2026-08-03 13:42:39 +02:00
2025-04-28 12:59:39 +03:00
2025-09-29 18:25:09 +03:00
2024-11-05 14:00:47 -08:00
2025-03-14 12:08:56 +04:00
2026-02-16 21:55:18 +01:00
2025-03-14 12:08:56 +04:00
2025-03-14 12:08:56 +04:00
2025-06-18 16:46:21 +10:00
2024-12-02 11:35:34 +02:00
2026-07-20 13:23:00 +03:00
2024-06-20 11:32:13 -04:00
2026-07-24 17:06:40 +02:00
2024-12-02 17:51:17 +02:00
2026-01-31 14:08:54 +01:00
2026-07-20 13:23:00 +03:00
2026-07-20 13:23:00 +03:00
2025-08-01 18:03:20 +02:00
2026-01-31 14:08:54 +01:00
2026-07-30 16:15:40 +02:00
2026-07-30 16:15:40 +02:00
2024-11-05 14:00:48 -08:00
2024-12-02 11:35:34 +02:00
2026-08-13 13:00:12 +03:00
2026-08-12 14:31:52 +03:00
2026-07-29 12:27:46 +02:00
2026-03-24 09:49:17 +02:00
2026-03-24 09:49:17 +02:00
2025-04-22 16:26:36 -04:00
2025-04-29 16:53:02 +02:00
2024-10-15 15:36:12 +11:00
2025-04-22 16:26:36 -04:00
2026-06-14 23:40:25 +05:30
2026-08-19 21:15:55 +03:00
2026-05-26 21:15:58 +02:00
2026-06-15 16:53:03 +02:00
2026-05-26 21:15:58 +02:00
2025-10-08 09:05:38 +02:00
2026-09-07 14:08:34 +12:00
2026-09-12 21:11:22 +07:00
2024-11-05 14:00:47 -08:00
2026-07-29 12:27:46 +02:00
2024-11-29 13:43:17 +02:00
2026-07-02 11:08:22 +10:00
2026-07-30 11:41:55 +02:00
2026-05-26 21:15:58 +02:00
2025-08-01 18:03:20 +02:00
2025-08-01 18:03:20 +02:00
2026-06-18 11:01:05 +03:00
2024-12-05 10:11:58 +01:00
2026-08-03 13:42:39 +02:00
2026-07-30 16:15:40 +02:00
2026-07-06 09:40:58 -04:00
2026-02-03 14:53:15 +01:00
2026-07-30 11:41:55 +02:00
2026-05-26 21:15:58 +02:00
2026-02-03 14:53:15 +01:00
2025-10-15 11:32:39 +04:00
2026-02-03 14:53:15 +01:00
2026-02-03 14:53:15 +01:00
2026-08-03 13:42:39 +02:00
2026-08-03 13:42:39 +02:00
2026-08-12 14:31:55 +03:00
2026-02-03 14:53:15 +01:00
2026-09-07 14:08:35 +12:00
2026-09-07 14:08:35 +12:00
2026-06-29 07:41:06 +03:00
2026-03-13 16:17:11 +01:00
2025-09-16 10:10:08 +05:30
2026-03-24 09:49:17 +02:00
2024-10-08 11:58:46 +02:00
2026-01-31 14:08:54 +01:00
2026-04-01 15:03:59 +03:00
2026-07-30 11:41:55 +02:00
2026-07-30 11:41:55 +02:00
2026-05-15 13:46:27 +04:00
2026-09-07 14:08:34 +12:00
2026-09-07 14:08:34 +12:00
2026-07-30 11:41:55 +02:00
2025-09-16 10:10:08 +05:30
2026-07-15 18:22:18 +10:00
2026-01-08 12:02:45 +01:00
2026-08-03 13:42:39 +02:00
2026-06-11 11:40:20 +10:00
2026-02-05 11:55:12 +11:00
2024-11-23 08:14:22 -07:00
2024-07-08 22:40:16 +02:00
2025-03-14 12:08:56 +04:00
2025-03-14 12:08:56 +04:00
2025-05-05 12:02:47 +07:00
2026-08-13 23:15:53 +04:00
2026-05-26 21:15:58 +02:00
2025-04-27 19:40:00 +02:00
2024-11-05 14:00:47 -08:00
2026-08-04 15:04:06 +10:00
2026-05-26 20:00:43 +04:00
2024-10-17 07:53:59 -06:00
2026-01-23 03:21:03 +01:00
2026-08-17 13:46:32 +03:00
2026-08-17 13:46:32 +03:00
2026-07-30 11:41:55 +02:00
2026-08-17 13:46:32 +03:00
2026-06-16 15:03:05 +02:00
2026-05-26 21:15:58 +02:00
2025-03-14 12:08:56 +04:00
2026-05-26 20:00:43 +04:00
2026-06-05 13:15:49 +04:00
2025-08-04 20:24:01 +02:00
2024-10-03 15:59:20 +10:00
2025-03-14 12:08:56 +04:00
2026-06-24 12:27:13 +02:00
2025-03-14 12:08:56 +04:00
2025-03-14 12:08:56 +04:00
2026-05-26 21:15:58 +02:00
2026-07-07 15:56:47 +02:00
2026-06-25 13:03:39 +05:30
2026-06-25 13:03:39 +05:30
2025-04-15 18:58:32 +02:00
2026-05-08 08:00:01 +02:00
2026-09-07 14:08:34 +12:00
2026-09-07 14:08:34 +12:00
2026-07-29 12:27:46 +02:00
2026-09-07 14:08:34 +12:00
2026-08-13 13:00:12 +03:00
2026-08-12 14:31:57 +03:00
2025-10-16 09:31:56 +12:00
2025-10-16 09:31:56 +12:00
2026-05-22 09:52:05 +02:00
2026-05-22 09:52:05 +02:00
2026-04-30 16:58:47 +07:00
2026-04-30 17:28:18 +07:00
2026-04-30 16:58:47 +07:00
2026-06-25 13:03:39 +05:30
2025-09-16 10:10:08 +05:30
2025-10-10 20:32:56 +07:00
2026-08-12 14:31:52 +03:00
2026-08-12 14:31:56 +03:00
2026-09-07 14:08:28 +12:00
2024-11-05 14:00:47 -08:00
2026-07-29 12:27:46 +02:00
2025-03-14 12:08:56 +04:00
2026-07-03 15:08:53 +03:00
2026-07-30 11:41:55 +02:00
2026-07-01 09:36:53 +05:30
2026-08-12 14:31:57 +03:00
2025-10-08 09:05:38 +02:00
2025-03-14 12:08:56 +04:00
2026-08-12 14:31:55 +03:00
2026-08-12 14:31:55 +03:00
2026-05-06 11:35:09 +10:00
2025-07-22 10:44:12 +10:00
2025-03-14 12:08:56 +04:00
2025-03-14 12:08:56 +04:00
2026-09-07 06:42:59 +12:00
2026-07-30 11:41:55 +02:00
2026-07-22 14:36:17 +02:00
2026-08-04 15:04:06 +10:00
2026-08-04 15:04:06 +10:00
2026-08-04 15:04:06 +10:00
2026-05-08 08:00:01 +02:00
2026-09-07 14:08:28 +12:00
2024-11-05 14:00:47 -08:00
2026-01-31 14:08:54 +01:00
2026-05-26 21:15:58 +02:00
2025-04-27 19:40:00 +02:00
2026-06-21 15:32:20 +02:00
2026-01-25 19:10:53 +01:00
2026-09-07 14:08:28 +12:00
2026-04-28 13:05:50 +03:00
2026-04-28 13:05:50 +03:00
2025-10-10 20:32:56 +07:00
2026-02-03 14:53:15 +01:00
2025-09-15 18:57:04 -06:00
2025-09-29 18:25:09 +03:00
2024-07-22 15:14:50 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-08-14 17:30:08 +02:00
2025-10-08 09:05:38 +02:00
2025-04-11 13:42:12 +02:00
2026-08-14 17:30:08 +02:00
2026-05-26 21:15:58 +02:00
2026-06-16 12:24:32 +02:00
2026-07-30 11:41:55 +02:00
2025-07-07 14:03:49 -06:00
2026-07-30 11:41:55 +02:00
2026-01-27 12:59:30 -07:00
2026-07-28 13:29:55 -06:00
2026-06-16 12:24:32 +02:00
2026-02-07 22:06:40 +01:00
2026-01-27 12:59:23 -07:00
2026-01-27 12:59:23 -07:00
2026-04-27 18:26:17 -06:00
2026-01-27 12:59:30 -07:00
2026-01-27 12:59:30 -07:00
2025-05-05 12:02:43 +07:00
2024-11-05 14:00:47 -08:00
2025-03-14 12:08:56 +04:00
2025-04-19 10:59:58 +04:00
2025-03-14 12:08:56 +04:00
2026-06-15 16:53:03 +02:00
2026-06-15 16:53:03 +02:00
2025-04-23 17:20:47 -06:00
2025-04-23 17:20:47 -06:00
2025-03-14 12:08:56 +04:00
2026-04-02 09:15:17 +03:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-05-26 21:15:58 +02:00
2026-07-20 13:23:00 +03:00
2026-05-15 13:30:21 +10:00
2026-04-30 17:22:36 +07:00
2025-10-15 11:32:39 +04:00
2026-08-14 17:30:08 +02:00
2026-04-27 18:26:17 -06:00
2025-03-14 12:08:56 +04:00
2026-02-06 17:46:50 +01:00
2025-11-04 12:39:27 +01:00
2026-04-06 15:16:38 +04:00
2026-04-06 15:16:38 +04:00
2026-08-13 23:15:53 +04:00
2026-08-13 23:15:53 +04:00
2026-07-14 14:22:31 +04:00
2026-08-13 23:15:53 +04:00
2026-08-13 23:15:53 +04:00
2026-08-13 23:15:53 +04:00
2025-08-01 18:03:20 +02:00
2026-07-30 16:15:40 +02:00
2026-04-06 15:16:38 +04:00
2026-04-06 15:16:38 +04:00
2026-08-13 23:15:53 +04:00
2026-08-13 23:15:53 +04:00
2026-07-30 11:41:55 +02:00
2026-07-19 16:35:20 +10:00
2025-09-04 18:08:39 +03:00
2026-08-27 16:10:40 +03:00
2026-08-27 16:10:40 +03:00
2026-05-26 21:15:58 +02:00
2024-06-24 13:09:47 +03:00
2026-08-03 13:42:39 +02:00
2026-07-30 11:41:55 +02:00
2026-06-15 15:15:10 +02:00
2026-06-15 15:15:10 +02:00
2024-11-05 14:00:47 -08:00
2026-09-11 11:06:14 +12:00
2026-08-12 14:31:57 +03:00
2025-03-14 12:08:56 +04:00
2026-01-08 21:41:40 +01:00
2026-08-04 15:04:06 +10:00
2026-08-04 15:04:06 +10:00
2025-10-08 09:05:38 +02:00
2026-02-24 14:48:11 +02:00
2025-10-08 09:05:38 +02:00
2024-11-05 14:00:50 -08:00
2026-04-02 09:15:17 +03:00
2025-03-14 12:08:56 +04:00
2026-09-07 14:08:34 +12:00
2026-09-14 15:46:48 +12:00
2026-01-31 14:08:54 +01:00
2026-01-05 20:34:44 +01:00
2026-07-30 11:41:55 +02:00
2025-05-03 12:06:36 +02:00
2026-03-24 09:49:17 +02:00
2024-11-05 14:00:47 -08:00
2024-11-05 14:00:47 -08:00
2026-06-29 07:40:04 +03:00
2026-01-08 12:02:45 +01:00
2026-07-30 16:15:40 +02:00
2026-07-30 16:15:40 +02:00
2026-08-03 13:42:39 +02:00
2026-02-06 17:46:51 +01:00
2026-03-17 18:57:42 +01:00
2026-08-12 14:31:54 +03:00
2026-02-02 08:07:28 +13:00
2026-07-20 13:23:00 +03:00
2026-07-30 16:15:40 +02:00
2026-04-15 21:49:26 +02:00
2025-04-19 10:59:58 +04:00
2026-02-06 17:46:51 +01:00
2026-02-06 17:46:51 +01:00
2026-09-11 11:06:14 +12:00
2026-09-07 14:08:28 +12:00
2025-09-29 18:25:09 +03:00
2024-06-20 11:32:13 -04:00
2024-06-27 10:26:09 +03:00
2025-08-04 12:05:53 +02:00
2024-11-05 14:00:47 -08:00
2025-05-05 12:02:48 +07:00
2024-12-02 17:51:17 +02:00
2026-05-28 17:27:57 +03:00
2026-08-03 13:42:39 +02:00
2025-09-19 12:31:14 +03:00
2025-10-08 09:05:38 +02:00
2025-10-08 09:05:38 +02:00
2026-08-12 14:31:55 +03:00
2026-08-12 14:31:57 +03:00
2026-08-13 23:15:53 +04:00
2026-08-13 23:15:53 +04:00
2026-06-24 12:27:13 +02:00
2025-03-14 12:08:56 +04:00
2024-11-05 14:00:47 -08:00
2026-04-06 15:00:16 +04:00
2026-05-26 21:15:58 +02:00
2026-04-09 17:25:40 +05:30
2026-04-09 17:25:40 +05:30
2025-02-12 10:17:44 +01:00
2025-03-14 12:08:56 +04:00
2025-08-04 12:05:53 +02:00
2026-09-07 14:08:35 +12:00
2026-10-20 08:31:36 +13:00
2026-09-07 14:08:35 +12:00
2026-09-07 14:08:35 +12:00
2026-10-20 08:31:36 +13:00
2026-09-14 15:47:37 +12:00
2026-09-14 15:47:37 +12:00
2026-10-20 08:13:29 +13:00
2026-09-07 14:08:35 +12:00
2026-07-20 13:23:00 +03:00
2026-07-30 11:41:55 +02:00
2024-07-03 12:45:30 +02:00
2026-08-04 15:04:06 +10:00
2026-08-04 15:04:06 +10:00
2026-08-04 15:04:06 +10:00
2026-08-13 23:15:53 +04:00
2026-08-13 23:15:53 +04:00
2025-07-29 13:15:02 +10:00
2026-07-06 13:44:56 +02:00
2026-08-12 14:31:52 +03:00
2025-01-09 09:41:38 +02:00
2026-08-03 13:42:39 +02:00
2026-02-09 15:28:24 +04:00
2026-04-16 09:26:39 +10:00
2026-03-11 08:05:08 +02:00
2025-03-14 12:08:56 +04:00
2024-12-02 17:51:17 +02:00
2026-06-26 07:32:21 +03:00
2026-07-30 11:41:55 +02:00
2026-08-03 13:42:39 +02:00
2026-01-23 03:21:03 +01:00
2024-07-10 12:17:09 +04:00
2026-10-20 08:13:29 +13:00
2026-10-20 08:13:29 +13:00
2026-05-27 12:49:36 +02:00
2025-10-08 09:05:38 +02:00
2026-05-26 21:15:58 +02:00
2024-10-15 10:50:22 +11:00
2026-09-01 17:53:48 +02:00
2026-09-01 17:53:48 +02:00
2024-06-20 11:32:13 -04:00
2025-10-08 09:05:38 +02:00
2026-08-12 14:31:54 +03:00
2026-08-12 14:31:52 +03:00
2026-08-12 14:31:57 +03:00
2026-08-12 14:31:57 +03:00
2026-08-03 13:42:39 +02:00
2026-07-30 16:15:40 +02:00
2026-04-01 10:49:05 +03:00
2026-03-17 18:57:42 +01:00
2025-10-08 09:05:38 +02:00
2026-07-28 13:14:38 +02:00
2026-08-13 23:15:53 +04:00
2026-02-07 22:12:32 +01:00
2025-04-29 11:18:00 +10:00
2024-06-20 11:32:13 -04:00
2026-05-26 21:15:58 +02:00
2026-02-09 15:28:24 +04:00
2026-05-22 09:52:05 +02:00
2025-08-01 18:03:20 +02:00
2026-09-07 14:08:34 +12:00
2026-05-22 09:52:05 +02:00
2026-05-22 09:52:05 +02:00
2025-04-19 10:59:58 +04:00
2025-03-14 12:08:56 +04:00
2025-04-19 10:59:58 +04:00
2026-07-02 19:01:25 +04:00
2026-04-06 15:16:38 +04:00
2025-08-01 18:03:20 +02:00
2025-08-01 18:03:20 +02:00
2026-07-30 16:15:40 +02:00
2026-04-06 15:00:16 +04:00
2026-08-03 13:42:39 +02:00
2026-08-03 13:42:39 +02:00
2025-03-14 12:08:56 +04:00
2024-12-02 17:51:17 +02:00
2026-05-26 21:15:58 +02:00
2026-08-11 11:32:01 +10:00
2026-04-30 09:41:26 -04:00
2026-07-30 16:15:40 +02:00
2026-06-15 16:53:03 +02:00
2025-03-14 12:08:56 +04:00
2026-08-13 23:15:53 +04:00
2025-04-19 10:59:58 +04:00
2026-03-13 16:17:11 +01:00
2026-03-13 16:17:11 +01:00
2026-08-13 23:15:53 +04:00
2024-06-20 11:32:13 -04:00
2026-09-07 14:08:28 +12:00
2026-05-26 21:15:58 +02:00
2026-06-24 12:27:13 +02:00
2026-06-18 16:14:40 +07:00
2026-08-03 13:42:39 +02:00
2026-08-04 15:04:06 +10:00
2026-07-20 13:23:00 +03:00
2025-02-12 10:17:44 +01:00
2025-04-29 11:18:00 +10:00
2026-03-24 09:49:17 +02:00
2024-06-20 11:32:13 -04:00
2024-07-09 13:20:49 +02:00
2025-09-04 18:08:39 +03:00
2025-03-14 12:08:56 +04:00
2024-06-24 13:09:47 +03:00
2026-01-23 03:23:20 +01:00
2025-08-04 14:58:10 +02:00
2025-09-30 17:37:12 +03:00
2025-10-08 09:05:38 +02:00
2025-03-14 12:08:56 +04:00
2026-05-22 09:52:05 +02:00
2024-12-02 17:51:17 +02:00
2024-12-02 11:35:34 +02:00
2026-04-06 15:00:16 +04:00
2025-09-15 18:57:04 -06:00
2026-05-05 13:57:50 +03:00
2026-09-07 14:08:34 +12:00
2025-01-21 12:18:56 +01:00
2025-03-14 12:08:56 +04:00
2025-03-14 12:08:56 +04:00
2025-09-10 15:03:59 +03:00
2026-06-16 12:24:32 +02:00
2025-08-04 14:58:10 +02:00
2025-11-28 12:56:27 +02:00
2025-11-25 13:01:26 +02:00
2024-06-10 23:29:05 +02:00
2026-01-08 12:02:45 +01:00
2026-07-30 11:41:55 +02:00
2024-06-20 11:32:13 -04:00
2025-08-04 14:58:18 +02:00
2026-06-24 17:31:40 +02:00
2024-06-20 11:32:13 -04:00
2024-06-27 10:26:09 +03:00
2026-07-20 13:23:00 +03:00
2026-06-04 09:23:29 +03:00
2026-06-21 15:32:20 +02:00
2025-10-14 14:47:35 +02:00
2026-06-15 16:53:03 +02:00
2026-04-02 09:15:17 +03:00
2025-12-15 14:47:15 +02:00
2024-09-01 02:48:19 +02:00
2024-10-03 13:24:43 +03:00
2024-09-09 13:50:38 +03:00
2026-08-03 13:42:39 +02:00
2026-06-04 09:23:29 +03:00
2026-01-08 12:02:45 +01:00
2024-06-20 11:32:13 -04:00
2026-02-07 22:12:32 +01:00
2026-01-20 10:23:44 +02:00
2025-07-14 08:21:50 +02:00
2026-08-03 13:42:39 +02:00
2026-07-29 12:27:46 +02:00
2026-06-25 14:49:32 +02:00
2026-06-04 09:23:29 +03:00
2025-10-08 14:15:04 +03:00
2026-04-21 13:00:39 +03:00
2026-06-05 13:15:49 +04:00
2024-10-16 13:23:47 +02:00