Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bcftools concat segfault if VCF files contain only headers #2286

Open
dpryan79 opened this issue Sep 26, 2024 · 3 comments · May be fixed by samtools/htslib#1845
Open

bcftools concat segfault if VCF files contain only headers #2286

dpryan79 opened this issue Sep 26, 2024 · 3 comments · May be fixed by samtools/htslib#1845
Labels
htslib-dependent Cannot be fixed until htslib is fixed

Comments

@dpryan79
Copy link

It seems that bcftools concat will segfault if the files it's combining have only headers:

$ bcftools concat -d exact -a -o combined.vcf.gz -O b --threads 1 bar.vcf.gz foo.vcf.gz
Checking the headers and starting positions of 2 files
Segmentation fault (core dumped)

I'll attach a header-only VCF file that can be easily used for testing (just copy it to bar.vcf.gz)
foo.vcf.gz

@pd3
Copy link
Member

pd3 commented Sep 26, 2024

Thank you for the test case, I can confirm it is reproducible. It is something that may need to be addressed in htslib.

@pd3 pd3 added the htslib-dependent Cannot be fixed until htslib is fixed label Sep 26, 2024
@dpryan79
Copy link
Author

@pd3 Thanks, that's the feeling I got when I ran it through valgrind. I honestly wasn't sure whether it made more sense to make the issue here or with htslib, since I imagine it's harder to reproduce on that repo.

pd3 added a commit to pd3/htslib that referenced this issue Oct 3, 2024
When an empty VCF file with a header but no data lines is indexed,
tbx_seqnames() called via bcf_sr_add_reader() returns an empty list.
Consequently, when bcf_sr_regions_next() is called and no in-memory
regions are available, it attempts to read from a file which is
not initialized.

This fixes samtools/bcftools#2286
@pd3 pd3 linked a pull request Oct 3, 2024 that will close this issue
@pd3
Copy link
Member

pd3 commented Oct 3, 2024

This will be fixed by samtools/htslib#1845

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
htslib-dependent Cannot be fixed until htslib is fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants