SIGSEGV: Illegal storage access. (Attempt to read from nil?)
I built the current head of the repo (e0131e3) on Centos 6.9 with the head of the nim repo (that was the only combination i was able to make work - had to use nim head b/c c2nim would not build on 0.17.2. had to use mosdepth head b/c the 0.2.0 release failed with a type error `mosdepth.nim(362, 10) Error: type mismatch: got (seq[int64], int64, int literal(0))`. could not use prebuilt binary b/c of old glibc). I'm using RUNPATHs in the executable instead of LD_LIBRARY_PATH for pcre and htslib (set with patchelf).  I'm testing with 1000g data and for the most part tests run fine except for intermittent segfaults:

```shell
$ mosdepth -n --by 500 -t3 HG00096_WGS \
    data/HG00096.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
```

The bam file is from `ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/phase3/data/HG00096/alignment/HG00096.mapped.ILLUMINA.bwa.GBR.low_coverage.20120522.bam`.

The segfaults seem to be happening only when using non-default values for the bam decompression threads (`-t`) but even then a couple of (identical) runs did finish without a segfault - i.e. it does not occur in 100% of runs.

