Skip to content

Free the imported schemas in the C Data pyarrow import tests - #477

Merged
CurtHagenlocher merged 1 commit into
apache:mainfrom
CurtHagenlocher:fix/cdata-test-schema-leaks
Oct 19, 2026
Merged

CurtHagenlocher merged 1 commit into
apache:mainfrom
CurtHagenlocher:fix/cdata-test-schema-leaks

Conversation

@CurtHagenlocher

@CurtHagenlocher CurtHagenlocher commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What's Changed

ImportArray, ImportRecordBatch, ImportGuidArray and ImportBool8Array in CDataInterfacePythonTests.cs allocate a CArrowSchema, have pyarrow export into it, and import it, but never call CArrowSchema.Free. The importer calls pyarrow's release callback, so what leaked was the CArrowSchema struct itself. They now free the schema right after importing it, as ImportDictionaryOfGuidArray does since #474, so a failing assertion can't skip the free.

This only changes tests. Every CArrowSchema.Create in the test projects now has a matching CArrowSchema.Free.

Tests

The full Apache.Arrow.Tests suite passes on net8.0, net462 and net472, with the pyarrow tests enabled.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

All four additions follow the importer’s ownership contract, with no unresolved issues.

No open issues 🎉

What changed in this PR

Fixes unmanaged schema-struct leaks in four pyarrow import tests without changing production code.

Changes:

  • Calls CArrowSchema.Free immediately after each schema import, before subsequent imports or assertions.
File Description
test/​Apache.Arrow.Tests/​CDataInterfacePythonTests.cs Frees schemas in array, record batch, GUID, and Bool8 import tests.

Review effort: Balanced

@CurtHagenlocher
CurtHagenlocher merged commit 78625e2 into apache:main Oct 19, 2026
14 checks passed
@CurtHagenlocher
CurtHagenlocher deleted the fix/cdata-test-schema-leaks branch October 19, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants