Skip to content

Navigation Menu

Sign in
Sign up

GH-51228: [Python] Raise instead of crashing on an invalid registry - #51247

Open
1fanwang wants to merge 3 commits into
apache:main from
1fanwang:1fannnw/gh-51228-call-tabular-registry
Open

GH-51228: [Python] Raise instead of crashing on an invalid registry #51247
1fanwang wants to merge 3 commits into
apache:main from
1fanwang:1fannnw/gh-51228-call-tabular-registry

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 8, 2026
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Contributor

Rationale for this change

pyarrow.compute.call_tabular_function() takes an optional registry argument. Passing the wrong Python type reaches an unchecked Cython cast to the native registry pointer, and the process dies with a SIGSEGV before Arrow can raise anything an application could catch.

What changes are included in this PR?

The binding validates the registry argument before the cast. A value of the wrong type raises TypeError("func_registry must be a FunctionRegistry").

Are these changes tested?

Yes. The regression drives the call in a subprocess so a crash is observable rather than fatal to the test run.

$ git checkout main -- python/pyarrow/_compute.pyx && python -m pytest \
 python/pyarrow/tests/test_compute.py -k tabular_function_rejects -q
E subprocess.CalledProcessError: Command '[...]' died with <Signals.SIGSEGV: 11>.
1 failed, 604 deselected in 0.56s
$ git checkout HEAD -- python/pyarrow/_compute.pyx && python -m pytest \
 python/pyarrow/tests/test_compute.py -k 'tabular_function_rejects or list_functions' -q
2 passed, 603 deselected in 0.30s

Are there any user-facing changes?

Yes. An invalid registry argument now raises TypeError instead of terminating the process.

This PR contains a "Critical Fix". It fixes a process crash reachable from ordinary Python input.

Validate call_tabular_function registry inputs before casting them to the native FunctionRegistry pointer.
Generated-by: GitHub Copilot CLI (Claude Opus 5)
Signed-off-by: Stefan Wang <1fannnw@gmail.com>
Copilot AI lite review requested due to automatic review settings September 8, 2026 19:52
@github-actions github-actions Bot added the awaiting review Awaiting review label Sep 8, 2026

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new subprocess-based test should be marked with @pytest.mark.processes so it can be skipped on platforms/configurations where process creation is disabled.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes a crash in the PyArrow compute bindings by validating the optional func_registry argument passed to pyarrow.compute.call_tabular_function() before performing the Cython cast, so invalid types raise a catchable TypeError instead of segfaulting.

Changes:

  • Add a runtime type check for func_registry in call_tabular_function() and raise TypeError on invalid values.
  • Add a regression test that runs the call in a subprocess to assert the failure mode is a Python exception (not a process crash).
File summaries
File Description
python/pyarrow/_compute.pyx Adds func_registry type validation before casting to a native registry pointer.
python/pyarrow/tests/test_compute.py Adds a subprocess-based regression test to ensure invalid registries raise TypeError rather than crashing.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/pyarrow/tests/test_compute.py
The test spawns a subprocess, which Emscripten does not support. Without
the marker the test runs there anyway and fails.
Generated-by: GitHub Copilot CLI (Claude Opus 5)
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings September 8, 2026 22:39
@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fix is narrowly scoped, matches the stated user-facing behavior, and is covered by a regression test that would fail under the prior segfaulting implementation.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@AlenkaF AlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to also add a check in _register_user_defined_function as every register_* function uses that?

Comment thread python/pyarrow/tests/test_compute.py
The subprocess wrapper guarded against the crash this change removes, so
the in-process form reads better now.
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI review requested due to automatic review settings September 10, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The added regression test should be executed in a subprocess (as described) to remain safe if the segfault regresses and to avoid crashing the test runner.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +249 to +252
def test_call_tabular_function_rejects_invalid_registry():
with pytest.raises(TypeError,
match="func_registry must be a FunctionRegistry"):
pc.call_tabular_function("", None, 1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it in-process per #51247 (comment); with the fix it raises rather than crashing.

AlenkaF commented Sep 11, 2026

Copy link
Copy Markdown
Member

Two things left:

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

Reviewers

@AlenkaF AlenkaF AlenkaF left review comments
Copilot code review Copilot
Copilot review effort, defaults to Lite
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@raulcd raulcd Awaiting requested review from raulcd raulcd is a code owner
@rok rok Awaiting requested review from rok rok is a code owner

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /