Skip to content

Commit

Permalink
BUG Badly formed inputs could crash ngless
Browse files Browse the repository at this point in the history
This is an upstream usage with ($$&), but badly formed files could crash
ngless with no error message, so refrain from using it. See:
cgaebel/stm-conduit#47
  • Loading branch information
luispedro committed Feb 7, 2017
1 parent baf1df1 commit e956504
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions NGLess/Interpret.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.List as CL
import qualified Data.Conduit as C
import Data.Conduit ((=$=), ($$+), ($$+-), ($$))
import Data.Conduit.Async (($$&))
import qualified Control.Concurrent.Async as A
import qualified Control.Concurrent.STM.TBMQueue as TQ
import qualified Data.Conduit.TQueue as CA
Expand Down Expand Up @@ -360,7 +359,7 @@ executePreprocess (NGOReadSet name rs) args (Block [Variable var] block) = do
(fp3', out3) <- runNGLessIO $ openNGLTempFile fp1 "preprocessed.singles." ".fq.gz"

[(q1, k1, s1) ,(q2, k2, s2) ,(q3, k3, s3)
,(pq1, pk1, ps1) ,(pq2, pk2, ps2) ,(pq3, pk3, ps3)] <- replicateM 6 shortReadVectorStats
,(_, pk1, ps1) ,(_, pk2, ps2) ,(_, pk3, ps3)] <- replicateM 6 shortReadVectorStats


let asSource "" _ = C.yieldMany []
Expand All @@ -382,15 +381,15 @@ executePreprocess (NGOReadSet name rs) args (Block [Variable var] block) = do
let mapthreads = max 1 (numCapabilities - 2)
zipSource2 (asSource fp1 q1) (asSource fp2 q2)
=$= asyncMapEitherC mapthreads (liftM splitPreprocessPair . vMapMaybeLifted (runInterpretationRO env . intercalate keepSingles) . uncurry V.zip)
$$& void $ C.sequenceSinks
$$ void $ C.sequenceSinks
[CL.map (\(a,_,_) -> a) =$= write out1 q1
,CL.map (\(_,a,_) -> a) =$= write out2 q2
,CL.map (\(_,_,a) -> a) =$= write out3 q3
]

asSource fp3 q3
=$= asyncMapEitherC mapthreads (vMapMaybeLifted (runInterpretationRO env . interpretPBlock1 block var))
$$& void (write out3 q3)
$$ void (write out3 q3)

forM_ [k1, k2, k3, pk1, pk2, pk3] release
liftIO $ forM_ [out1, out2, out3] hClose
Expand Down

0 comments on commit e956504

Please sign in to comment.