It seems using a process substitution for extraction regions can cause issues with --write-index. I ran almost the same command on the same data using the two-pass approach in #2118 and never hit this issue, so may be related to the region list already being consumed before freeing at the end?
# error
samtools faidx --write-index -r <(echo -e "1\n2\n3") -o region.fa.gz genome.fa.gz
free(): invalid next size (fast)
Aborted
# no error
echo -e "1\n2\n3" > temp.txt
samtools faidx --write-index -r temp.txt -o region.fa.gz genome.fa.gz
GDB tracked the error back to this free, but all the variables were optimised out despite trying to recompile htslib/samtools more debug friendly.
This was run with
samtools 1.21-13-g86fd06e-dirty
Using htslib 1.21-15-g1d2e493b-dirty
-Alex
It seems using a process substitution for extraction regions can cause issues with
--write-index. I ran almost the same command on the same data using the two-pass approach in #2118 and never hit this issue, so may be related to the region list already being consumed before freeing at the end?GDB tracked the error back to this free, but all the variables were optimised out despite trying to recompile htslib/samtools more debug friendly.
samtools/faidx.c
Line 666 in 86fd06e
This was run with
-Alex