Closed 23andme-jaredo closed 5 months ago
Can you also show the command and the version of the program? I was not able to reproduce the problem with the latest version
Sorry, this was bcftools-1.19 on centos7:
$ valgrind bcftools stats -s - test.vcf > /dev/null
==31004== Memcheck, a memory error detector
==31004== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==31004== Using Valgrind-3.17.0 and LibVEX; rerun with -h for copyright info
==31004== Command: bcftools stats -s - test.vcf
==31004==
==31004== Invalid read of size 4
==31004== at 0x4129DB: update_vaf (vcfstats.c:943)
==31004== by 0x4129DB: do_sample_stats (vcfstats.c:1140)
==31004== by 0x414D2F: do_vcf_stats (vcfstats.c:1293)
==31004== by 0x414D2F: main_vcfstats (vcfstats.c:2019)
==31004== by 0x5A97554: (below main) (in /usr/lib64/libc-2.17.so)
==31004== Address 0x9914e4c is 1,371,500 bytes inside an unallocated block of size 2,281,216 in arena "client"
==31004==
==31004==
==31004== HEAP SUMMARY:
==31004== in use at exit: 0 bytes in 0 blocks
==31004== total heap usage: 252 allocs, 252 frees, 1,895,324 bytes allocated
==31004==
==31004== All heap blocks were freed -- no leaks are possible
==31004==
==31004== For lists of detected and suppressed errors, rerun with: -s
==31004== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)
the value of idx is >20 which is causing the problem.
Better to calculate vaf = AD[i]/sum(AD)
?
Thank you for the bug report, this is now fixed.
thanks!
This is a weird edge case I found with the output of GLNexus jointcalling. I have created an extreme toy example here since I found the issue in non-public data and the memory error was sporadic there. I guess in practice there is some interaction between low resolution reference intervals and the joining of indels across samples that create some slight inconsistency between AD/DP.
Obviously the input is invalid (although within spec?) but it would be nice to not segfault here:
problem is here:
https://github.com/samtools/bcftools/blob/develop/vcfstats.c#L938-L944
I guess you could go
#define vaf2bin(vaf) min(20,((int)nearbyintf((vaf)/0.05)))
as a crude fix.