Memory corruption crash from ASOF join over the recursive CTE
Author: wanteatfruitCreated Sep 30, 2026Updated Sep 30, 2026
Labelsreproduced
What happens?
Memory corruption crash from ASOF join over the recursive CTE
To Reproduce
CREATE TABLE b (k INTEGER); INSERT INTO b VALUES (1);
CREATE VIEW l1 AS WITH RECURSIVE r AS (SELECT k, 0 AS l FROM b UNION ALL SELECT k, l+1 FROM r WHERE l < 0) SELECT k FROM r;
CREATE VIEW t AS SELECT x.k FROM l1 AS x ASOF LEFT JOIN l1 AS y ON x.k >= y.k;
WITH RECURSIVE q(n) AS (SELECT min(k) FROM t UNION ALL SELECT n+1 FROM q WHERE n < (SELECT max(k) FROM t)) SELECT count(*) FROM q;
-- "Not implemented Error: AsOf joins are not supported in recursive CTEs yet"
WITH RECURSIVE q(n) AS (SELECT min(k) FROM t UNION ALL SELECT n+1 FROM q WHERE n < (SELECT max(k) FROM t)) SELECT count(*) FROM q;
-- When run again
-- corrupted double-linked list
-- [1] 85164 trace trap duckdbPotential root cause: a debug build's sanitizer points to a use-after-free at executor.cpp:331.
- The inner recursive CTE's operator gets registered with the executor.
- Then the ASOF join throws the "not implemented" error, and the plan is freed.
- On the way out, Executor::CancelTasks still uses the registered operator, which is now freed. Executor::Reset() never clears that registration list.
OS:
macOS
DuckDB Version:
v2.0.0-alpha43763
DuckDB Client:
CLI
Hardware:
No response
Full Name:
Junwen An
Affiliation:
NUS
Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?
- Yes, I have
Did you include all code required to reproduce the issue?
- Yes, I have
Did you include all relevant data sets for reproducing the issue?
Yes
Source: duckdb/duckdb