ablab / VerityMap

GNU General Public License v3.0
30 stars 5 forks source link

frequent signal 11 / sigsegv #19

Open ptrebert opened 2 years ago

ptrebert commented 2 years ago

Hi, I have executed VerityMap on a number of haploid chromosomes w/o problems, but for the majority, then run fails with a segfault like this

[...]
00:00:38 0.72022-06-28 12:58:44 VerityMap started

*********************************
Read mapping started...
MAPPER_BIN exists
[...Python traceback omitted...]
subprocess.CalledProcessError: Command 
'['[ ...cut... ]/veritymap/build/bin/veritymap', '--target', 'output/subset_wg/20_extract_contigs/NA20509.HIFIRW.ONTUL.na.chrY.fasta',
 '--queries', 'output/subset_wg/45_extract_reads/NA20509.HIFIRW_aln-to_HIFIRW.ONTUL.na.chrY.reads.fasta.gz', 
'-o', '[ ...cut... ]/output/eval/assm_errors/NA20509.HIFIRW.ONTUL.na.chrY.HIFIRW/veritymap', 
'-t', '6', '--config', 'hifi']' died with <Signals.SIGSEGV: 11>.

I get the segfault for both HiFi and ONT reads. I have the info from other users that the mapper sometimes crashes but has already produced all necessary output. If that is the case here as well, can you briefly state which output file(s) are required to move on with the run:

alignments.sam
chains.tsv
kmer_indexes.tsv
norarekmers.bed

All of the above? In that case, I would modify the script to check for the existence of these files and ignore the error in that case.

Best, Peter

seryrzu commented 2 years ago

Hi Peter,

I would like to figure out what causes the sigfault to fix it. Can you please share input files via email (abzikadze@ucsd.edu) or via slack?

Technically, alignments.sam is what you are likely looking for, but I'm not sure if the file is complete.

Thanks, Andrey

ptrebert commented 2 years ago

Sure, but given the size, I am sharing via Globus (you should have received an email invite).

Thanks for looking into it!

steven-solar commented 1 year ago

Was this resolved? Running into the same problem. My command:

python /path/to/tools/VerityMap/veritymap/main.py \
    -t $SLURM_CPUS_PER_TASK \
    --reads ../../2-bam-to-fq/siamang.chrY-reads.fq \
    -d ont-haploid-complete \
    -o chrY ../../3-get-chrY-refs/siamang.chrY.fa

Output:

2023-06-14 17:05:10 VerityMap started

*********************************
Read mapping started...
Traceback (most recent call last):
  File "/path/to/tools/VerityMap/veritymap/main.py", line 61, in <module>
    main()
  File "/usr/local/Anaconda/envs/py3.8/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Anaconda/envs/py3.8/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/Anaconda/envs/py3.8/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Anaconda/envs/py3.8/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/path/to/tools/VerityMap/veritymap/main.py", line 54, in main
    do(assemblies, reads_fname, datatype, out_dir, threads, no_reuse, is_careful)
  File "/path/to/tools/VerityMap/veritymap/../veritymap/py_src/mapper.py", line 148, in do
    run_mapper(assembly, reads_fname, out_dir, threads, datatype, is_careful)
  File "/path/to/tools/VerityMap/veritymap/../veritymap/py_src/mapper.py", line 40, in run_mapper
    subprocess.check_call(cmd)
  File "/usr/local/Anaconda/envs/py3.8/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/path/to/tools/VerityMap/veritymap/build/bin/veritymap', '--target', '../../3-get-chrY-refs/siamang.chrY.fa', '--queries', '../../2-bam-to-fq/siamang.chrY-reads.fq', '-o', '/path/to/veritymap', '-t', '56', '--config', 'ont-haploid-complete']' died with <Signals.SIGSEGV: 11>.
skoren commented 1 year ago

I see similar issues with several assemblies, including HG002. In at least one case, the cause was a very repetitive contig (rDNA model sequence) and removing it ran to completion. I'm still looking into the other cases but my guess is it is related to finding no k-mers in some subset of sequences.

skoren commented 1 year ago

I think I fixed it by updating the following:

.6d2071a 100644
--- a/veritymap/src/projects/veritymap/kmer_index/index_builders/kmer_window.hpp
+++ b/veritymap/src/projects/veritymap/kmer_index/index_builders/kmer_window.hpp
@@ -61,7 +61,7 @@ class KmerWindow {
   void Reset() {
     next_it = pos_hash_regular.cbegin();
     cur_it = pos_hash_regular.cbegin();
-    IncRight();
+    if (pos_hash_regular.size() > 0) IncRight();
   }
 };

This was the location of the segfault I was seeing consistently where no k-mers are selected and the IncRight step was then dereferencing the empty iterator. Still running tests to make sure it doesn't crash elsewhere.