Skip to content

Fix recursive outer nested loop join state reuse - #24700

Open
kryonix wants to merge 1 commit into
duckdb:mainfrom
kryonix:fix-duckfuzz-4635
Open

Fix recursive outer nested loop join state reuse#24700
kryonix wants to merge 1 commit into
duckdb:mainfrom
kryonix:fix-duckfuzz-4635

Conversation

@kryonix

@kryonix kryonix commented Aug 11, 2026

Copy link
Copy Markdown
Member

A recursive CTE containing a FULL or RIGHT outer nested loop join could fail when the recursive executor reused its local source state. Assertion builds failed while initializing an already initialized scan chunk, while release builds could retain duplicate vectors and eventually access them out of bounds.

The local source reset path was calling OuterJoinMarker::InitializeScan on every recursive iteration. That function performs one-time initialization of the scan chunk, so calling it again violated the chunk lifecycle.

I moved that initialization into the nested loop join local scan state constructor. Reusing the state now resets the existing chunk and replaces its scan bookkeeping without reconstructing its schema or vector cache. This preserves recursive state reuse while giving each iteration a clean outer-join scan.

Fixes duckdb/duckdb-fuzzer#4635.

Fixes https://github.com/duckdblabs/duckdb-internal/issues/9824.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

1 participant