Skip to content

VCF-53: Fix read_variant_stats() segfault when region is empty#871

Merged
alancleary merged 4 commits intomainfrom
alancleary/VCF-53
Jan 22, 2026
Merged

VCF-53: Fix read_variant_stats() segfault when region is empty#871
alancleary merged 4 commits intomainfrom
alancleary/VCF-53

Conversation

@alancleary
Copy link
Copy Markdown
Member

The issue was caused by the code that converts VCF read buffers into Arrow arrays assuming that the buffers would not be empty. read_variant_stats() now returns an empty Arrow Table with the correct schema if the read buffers are empty. The read_allele_count() method was updated to do the same. Previously it returned None when the read buffers are empty, which needlessly complicates downstream parsing and aggregation.

These edge cases are to handle when the buffers returned by a dataset read are empty. Specifically, an array's offsets must still contain the initial 0 value even when there's no data, and a string array must always have 3 buffers, even when there's no data.
…rrow tables

Previously the allele count binding would be return None and the variant stats binding would try to parse the empty buffers returned by the reader, causing a segmentation fault.
…nt()

These tests ensure that both methods return an empty DataFrame when the regions are empty or don't match the constraints of the query.
@alancleary alancleary requested a review from jp-dark January 21, 2026 22:46
@alancleary
Copy link
Copy Markdown
Member Author

Note that the CLI failure will be fixed by PR #870.

Copy link
Copy Markdown
Collaborator

@jp-dark jp-dark left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

@alancleary alancleary merged commit 5f5d692 into main Jan 22, 2026
11 checks passed
@alancleary alancleary deleted the alancleary/VCF-53 branch January 22, 2026 16:36
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