Closed xunjieli closed 5 years ago
@mlin I ran into a SEGV when GLnexus is dereferencing uninitialized bcf1_t.d
. This is to fix it.
@xunjieli Thanks! Do you have a reliable repro case for the original segfault? I'd prefer to look into the root cause a little more. The thing is, I think the bcf1_t
objects manipulated at this point should already have been unpacked here:
So I'm worried something more complicated is going wrong even if this patch seems to fix the crash.
Thanks @mlin. I am not using BCFKeyValueData
. I have an implementation of BCFData
that returns a valid bcf1_t
, but it wasn't unpacked.
I thought about unpacking it myself in the implementation of BCFData, but that's likely to be inefficient since there are other filtering going on, and is probably the best for the genotyper to unpack it before accessing the d
field.
@xunjieli Ah, if I may say so, we had put in the BCFData "contract"
I believe bcf_unpack
is smart enough not to repeat work it's already done, so it shouldn't hurt to do it in prepare_dataset_records
again. However, we need to keep the invocation in revise_genotypes
too. That one comes right after we make a fresh copy of the record in order to mutate it (also per above contract) so the copy needs to be unpacked.
@mlin Thanks for pointing that out. I missed that note in the header file.
bcf1_t's d field is accessed in preprocess_record, but bcf_unpack is called in revise_genotypes which happens later. This moves bcf_unpack before bcf1_t's d field is accessed.