Skip to content

GH-55277: [C++][Gandiva] Fix stack overflow in decimal evaluation with JIT optimization disabled - #55278

Draft
dmitry-chirkov-dremio wants to merge 2 commits into
apache:mainfrom
dmitry-chirkov-dremio:gh-55277-gandiva-decimal-stack-regression
Draft

dmitry-chirkov-dremio wants to merge 2 commits into
apache:mainfrom
dmitry-chirkov-dremio:gh-55277-gandiva-decimal-stack-regression

Conversation

@dmitry-chirkov-dremio

@dmitry-chirkov-dremio dmitry-chirkov-dremio commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

Gandiva can exhaust the stack when evaluating decimal expressions with JIT optimization disabled. Decimal return slots are allocated inside the record loop, so each row uses more stack. The stack is only released when the function returns.

What changes are included in this PR?

Move return-slot allocations to the function entry block in CallDecimalFunction and AddLarge.

Are these changes tested?

Locally, the large-batch test crashes before the fix (SIGSEGV, exit 139) and passes afterward. It checks negative values and nulls, with optimization off and on.

Are there any user-facing changes?

No.

This PR contains a "Critical Fix". It fixes a native process crash.

Was AI used for this PR?

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

PR code and description written by:

  • [X ] Human
  • AI

Reviewed before submission by:

  • Human
  • AI

GitHub Issue: #55277

P.S. The first commit contains only the regression test. The second commit contains only the fix.

…overflow

Add a large-batch decimal cast test to reproduce stack exhaustion with JIT optimization disabled.

AI tools helped investigate the crash and write the test.
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55277 has been automatically assigned in GitHub to PR creator.

@dmitry-chirkov-dremio dmitry-chirkov-dremio changed the title GH-55277: [C++][Gandiva] Add regression for decimal cast stack overflow GH-55277: [C++][Gandiva] Fix stack overflow in decimal expressions with optimization disabled Oct 27, 2026
@dmitry-chirkov-dremio dmitry-chirkov-dremio changed the title GH-55277: [C++][Gandiva] Fix stack overflow in decimal expressions with optimization disabled GH-55277: [C++][Gandiva] Fix stack overflow in decimal evaluation with JIT optimization disabled Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant