Skip to content

DX-128819: [C++][Gandiva] Validate the input expression of IN (cherry-pick apache/arrow#55609) - #175

Merged
lriggs merged 1 commit into
dremio:dremio_27.0_26_20from
victor6567758:DX-128819-arrow-55609-dremio_27.0_26_20
Dec 1, 2026
Merged

lriggs merged 1 commit into
dremio:dremio_27.0_26_20from
victor6567758:DX-128819-arrow-55609-dremio_27.0_26_20

Conversation

@victor6567758

@victor6567758 victor6567758 commented Nov 30, 2026 •

Copy link
Copy Markdown

Summary

Cherry-pick of apache#55609 (1140d8e35c1a5dc7eb32515255f12816ba4a0dec, merged 2026-11-27) into dremio_27.0_26_20. Same change as #174 (dremio_27.0_23_19).

apacheGH-55615: Gandiva ExprValidator did not validate the input expression of IN, and a null input expression crashed Projector::Make with SIGSEGV (InExpressionNode::ToString() dereferenced it before validation).

  • the validator now rejects a null input / null type and visits the input expression
  • ToString() prints null for a null input
  • Projector::Make / Filter::Make return ExpressionValidationError instead of crashing

Jira: DX-128819

Files

  • cpp/src/gandiva/expr_validator.cc
  • cpp/src/gandiva/node.h
  • cpp/src/gandiva/tests/projector_build_validation_test.cc (4 new tests)

Cherry-picked with -x, upstream author preserved.

Testing

C++ unit tests (gandiva-projector-test --gtest_filter='*TestInExpression*', run on the dremio_27.0_26_20 branch, same change on both):

  • with the fix: the 4 new tests pass
  • fix reverted: TestInExpressionValidatesEvalExpression fails and TestInExpressionNullEvalExpression crashes with SIGSEGV

JarBuild (dremio/arrow-java, built from this PR branch):

Dremio-side regression check (local Dremio on master (consumer of this branch) with the jar above): 9 queries with IN (column, arithmetic, CASE, function, varchar, date, decimal, WHERE IN, NOT IN with NULL) run with Gandiva (exec.gandiva.optimize_ir false/true) and Java codegen. All results identical, no errors in the server log. A null/invalid IN input cannot be created from SQL (the planner type-checks first), so the crash itself is covered by the C++ tests only.

…on of IN (apache#55609)

`ExprValidator` checks the value list of `IN` but not its input expression. An `IF` with an `int32` condition is rejected alone and accepted under `IN`. A null input crashes `Projector::Make` with SIGSEGV.

The PR has the tests first, then the fix in `expr_validator.cc` and `node.h`.

`ValidateInExpression` checks that the input and its type are not null, and visits the input. `InExpressionNode::ToString()` prints `null` for a null input, so the cache key does not crash before validation.

Yes. The new tests cover invalid, null and untyped input for all `IN` value types, with `Projector::Make` and `Filter::Make`, and a valid `IN`. On main, one of them fails and two crash with SIGSEGV. All of them pass with the fix.

`Make` now returns `ExpressionValidationError` for an `IN` with an invalid or null input. Before, it accepted it or crashed.

**This PR contains a "Critical Fix".** It fixes a crash. `Projector::Make` and `Filter::Make` die with SIGSEGV (exit code 139) when the input expression of an `IN` node is null. The null pointer is dereferenced in `InExpressionNode::ToString()`, which the cache key calls before the validator runs. Both `Make` calls now return `ExpressionValidationError`.

AI tools helped investigate the bug and write the fix, tests, and description.

**PR code and description written by:**
- [x] Human
- [x] AI

**Reviewed before submission by:**
- [x] Human
- [ ] AI
- [ ] Not reviewed

* GitHub Issue: apache#55615

Authored-by: Dmitry Chirkov <dmitry.chirkov@dremio.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
(cherry picked from commit 1140d8e)
@lriggs
lriggs merged commit 56df860 into dremio:dremio_27.0_26_20 Dec 1, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants