Differential JOIN reads out of range for a nonempty nullary keyed left
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #2212 by @justinjoy — merged
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 54/100
Research direction
Start in wirelog/columnar/join.c at wl_columnar_join_diff_op and compare its nullary left-input validation with the ordinary operator. Then inspect wirelog/columnar/diff_join_batch.c and the bounds check in join_batch.c; add the regression cases described for nonempty and empty zero-column left inputs, including the bounded mode. Done when the invalid keyed case returns EINVAL without changing the stack or reservations, while the empty case still returns an empty result.
Written by the indexing model from the issue text.
Description
A nonempty nullary (zero-column) left input to a keyed differential JOIN can read past the left relation's column metadata.
Where
wl_columnar_join_diff_op(wirelog/columnar/join.c) resolves each key withcol_op_resolve_key, which falls back to column 0 when the name is not found.col_join_key_types_compatiblethen readscolumn_types[lk[k]]without checkinglk[k] < left->ncols; for a zero-column left that index is out of range.- The bounded differential producer (
col_diff_join_batch_producer_create,wirelog/columnar/diff_join_batch.c) has nolk[k] < left->ncolscheck either; the ordinary producer has one (join_batch.c, returnsEINVAL).
3be9ba28 ("reject nonempty nullary keyed left inputs") added the rejection to the ordinary operator (wl_columnar_join_op) only. Found during the #1382 review (finding Y2); it predates #1382, which only changed how the differential operator records and refuses excluded shapes.
Fix
- Mirror the
3be9ba28check inwl_columnar_join_diff_opbefore the materialization cache lookup and the bounded-mode decision: a nonempty left withncols == 0andkey_count > 0returnsEINVAL. - Add the
lk[k] < left->ncols(and right) bounds check tocol_diff_join_batch_producer_create, as the ordinary producer has.
Tests
- A keyed differential JOIN over a nonempty zero-column left returns
EINVALand leaves the stack and reservations unchanged, with the knob off and atWIRELOG_JOIN_BATCH_BYTES=224, under ASan/UBSan. - An empty zero-column left still yields an empty result (the
#2170case).
- Dominant language
- C
- Stars
- 18
- Forks
- 2
- Avg merge
- 7h 5m
- Merged PRs (30d)
- 240
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from semantic-reasoning/wirelog
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
semantic-reasoning/wirelog#2229 ·
Maintainers usually reply within 1 day
-
Doc: insert executor and incremental consolidation leave sorted runs, not globally sorted headsOpen
Difficulty 1/5 Under an hour Newbie friendliness 83/100
semantic-reasoning/wirelog#2133 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
semantic-reasoning/wirelog#2042 ·
Maintainers usually reply within 1 day
-
p2-medium
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
semantic-reasoning/wirelog#1914 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
semantic-reasoning/wirelog#2231 ·
Maintainers usually reply within 1 day
All issues in semantic-reasoning/wirelog
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
colbymchenry/codegraph#2770 ·
Maintainers usually reply within 1 day
-
area/ysql kind/enhancement priority/medium status/awaiting-triage
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
yugabyte/yugabyte-db#35578 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
interpreter-core type-feature
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day