blachlylab / dhtslib

D bindings and OOP wrappers for htslib
MIT License
7 stars 1 forks source link

VCFWriter ctor incorrect #116

Closed charlesgregory closed 2 years ago

charlesgregory commented 3 years ago

VCFWriter invariant block is incorrect and blocks compilation in debug mode.

https://github.com/blachlylab/dhtslib/blob/0f284df0d57f973fb0a0e2b96af059d59bfb8975/source/dhtslib/vcf/writer.d#L65-L68

jblachly commented 3 years ago

weird that this wasn't caught by unit tests, which run in debug mode, no?

charlesgregory commented 3 years ago

Actually I can't recreate the issue and dhtslib.vcf.writer has 100% coverage. Must have been some quirk when updating dhtslib downstream. Closing for now.

charlesgregory commented 3 years ago

Actually found it, doesn't block compilation has an assert thrown at runtime. It's not the invariant actually the ctor that's incorrect at line 61 VCFHeader * should be VCFHeader. Since using a VCFHeader doesn't trigger either of the static if blocks the header goes uninitialized. https://github.com/blachlylab/dhtslib/blob/0f284df0d57f973fb0a0e2b96af059d59bfb8975/source/dhtslib/vcf/writer.d#L54-L63

charlesgregory commented 3 years ago

It isn't caught by our unittests as all our unittests don't supply either a bcf_hdr_t* or a VCFHeader as input. The default ctor that isn't supplied some form of header will just call bcf_hdr_init.