Skip to content

GH-44643: [C++][Python] Fix map conversion abort after child capacity error - #55717

Open
lll-hhh wants to merge 1 commit into
apache:mainfrom
lll-hhh:fix/map-builder-rewind-44643
Open

lll-hhh wants to merge 1 commit into
apache:mainfrom
lll-hhh:fix/map-builder-rewind-44643

Conversation

@lll-hhh

@lll-hhh lll-hhh commented Nov 22, 2026

Copy link
Copy Markdown

Rationale for this change

Fixes #44643.

When a Python struct row is converted, its child builders are appended one at a time. If a later child returns CapacityError, earlier children may already contain part of that row. The chunker then finishes the current chunk, and MapBuilder::FinishInternal aborts because the key and item builders have different lengths.

What changes are included in this PR?

  • Make PyStructConverter recover from a child CapacityError by backfilling any missing child values and the struct parent. This leaves a complete placeholder row for the chunker to slice away.
  • Mark the struct converter as requiring rewind on overflow and stop Chunker from retrying when no logical rows were committed to the current chunk.
  • Release the new reference returned by PyMemoryView_GetContiguous() so a temporary memoryview/mmap can be released after conversion.
  • Add regressions for the abort, successful automatic chunking of a map of strings, and memoryview buffer release.

Are these changes tested?

Yes, against an editable Arrow C++/PyArrow build in WSL:

  • Focused regressions with large-memory tests enabled: 3 passed.
  • python -m pytest -q pyarrow/tests/test_convert_builtin.py: 612 passed, 72 skipped, 2 xfailed.
  • Arrow C++/PyArrow shared build completed successfully.
  • clang-format==18.1.8 --dry-run --Werror passed on all modified C++ files.

Are there any user-facing changes?

No API changes. Oversized map/struct conversions now either split into chunks or raise ArrowCapacityError instead of aborting the Python process.

This PR contains a "Critical Fix". This fixes a process-wide SIGABRT on an API-contract-valid input path.

Was AI used for this PR?

In accordance to the AI generation guidelines, AI was used for implementation and tests. The change was reproduced, debugged, reviewed, and validated against a local Arrow build before submission.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Copilot AI balanced review requested due to automatic review settings November 22, 2026 06:36

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

[Python][C++] Calling Table.from_pandas with a dataframe that contains a map column of sufficient size causes SIGABRT and process crash

2 participants