xiaochuanle / MECAT

MECAT: an ultra-fast mapping, error correction and de novo assembly tool for single-molecule sequencing reads
107 stars 26 forks source link

seg fault in 3-overlapErrorAdjustment #44

Open flowers9 opened 6 years ago

flowers9 commented 6 years ago

There's a small bug in mecat2canu/src/overlapErrorAdjustment/FindError.C that, with some data sets, can cause repeatable segmentation fault errors. Specifically, if there's a gap in read ids of greater than FRAGS_PER_BATCH, Extract_Needed_Frags() can generate a null list (no reads or basepairs) and then attempt to load a read anyway (causing a seg fault).

It's not an algorithm error, it's just a loop that needs to be skipped (if the looping continues properly, it'll catch up to the higher read id after some boring null extractions). So, it's a simple fix - just check hiID vs fi at the top of the routine:

--- findErrors.C.orig 2018-03-08 11:22:00.553731726 -0600 +++ findErrors.C 2018-03-08 11:22:29.777560012 -0600 @@ -86,6 +86,7 @@ uint32 ii = 0; // Index into reads arrays uint32 fi = G->olaps[lastOlap].b_iid; // Actual ID we're extracting

+ if (hiID < fi) return; assert(loID <= fi);

fprintf(stderr, "Extract_Needed_Frags()-- Loading used reads between "F_U32" and "F_U32".\n",