Repository navigation
GH-55615: [C++][Gandiva] Validate the input expression of IN - #55609
Conversation
The tests cover an invalid, a null and an untyped input expression of IN, for Projector::Make and Filter::Make. They fail or crash on main. The fix is in the next commit.
ExprValidator checked the value list of IN but not its input expression. An invalid input was accepted and a null input crashed Make. The validator now rejects a null input or type and visits the input. InExpressionNode::ToString() prints null for a null input, so the cache key does not crash before validation.
|
Thanks for opening a pull request! This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format. If this is not a minor PR, could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or After updating the title, you can mark the pull request as ready for review. See also: |
|
CI results for the new tests. Tests-only commit, before the fix:
The crash is in Different from what I predicted: the crash stops the binary, so With the fix commit, A few known failures seen previously also appeared. They are not related to this PR. |
|
|
|
@lriggs @akravchukdremio @xxlaykxx please review |
xxlaykxx
left a comment
There was a problem hiding this comment.
🟢 Verdict: No issues found — the fix is correct and minimal, and the new tests cover both the missed validation and the crash.
What I checked
- The null-type check is necessary, not just defensive:
Visit(LiteralNode)dereferencesreturn_type(), so without it the untyped-literal test would crash inside the validator instead of returning an error. - Ordering in
ValidateInExpressionis right: null check, thenAccept, then the type comparison. The decimal specialization duplicating the call (notype()accessor) matches the pre-PR shape. - The
"null"placeholder inToString()cannot collide with a real expression's cache key, since field, literal and function nodes all print a type prefix or function name.
Minor, non-blocking
FunctionNode::ToString()already usesuntypedfor a missing type. Usinguntyped(or(null)) here instead ofnullwould keep the cache-key vocabulary consistent and avoid confusion with Arrow'snulldata type name. Cosmetic only.Visit(IfNode),Visit(FunctionNode)andVisit(BooleanNode)have the same pre-existing gap: they dereference children and child return types without null checks. Out of scope here, but possibly worth a follow-up issue ifMakeshould be robust against any malformed tree.
AI-assisted analysis
Rationale for this change
ExprValidatorchecks the value list ofINbut not its input expression. AnIFwith anint32condition is rejected alone and accepted underIN. A null input crashesProjector::Makewith SIGSEGV.What changes are included in this PR?
The PR has the tests first, then the fix in
expr_validator.ccandnode.h.ValidateInExpressionchecks that the input and its type are not null, and visits the input.InExpressionNode::ToString()printsnullfor a null input, so the cache key does not crash before validation.Are these changes tested?
Yes. The new tests cover invalid, null and untyped input for all
INvalue types, withProjector::MakeandFilter::Make, and a validIN. On main, one of them fails and two crash with SIGSEGV. All of them pass with the fix.Are there any user-facing changes?
Makenow returnsExpressionValidationErrorfor anINwith an invalid or null input. Before, it accepted it or crashed.This PR contains a "Critical Fix". It fixes a crash.
Projector::MakeandFilter::Makedie with SIGSEGV (exit code 139) when the input expression of anINnode is null. The null pointer is dereferenced inInExpressionNode::ToString(), which the cache key calls before the validator runs. BothMakecalls now returnExpressionValidationError.Was AI used for this PR?
AI tools helped investigate the bug and write the fix, tests, and description.
PR code and description written by:
Reviewed before submission by: