luispedro / conduit-algorithms

Conduit based algorithms
http://luispedro.org
Other
2 stars 2 forks source link

async exception safety #9

Open nh2 opened 5 years ago

nh2 commented 5 years ago

I just came across this library while packaging up an older gist of mine, https://gist.github.com/nh2/321567bb68e9efa6e299eb6b2410a1fb, which implements

conduitPooledMapMBuffered :: (MonadIO m, MonadBaseUnlift IO m, MonadResource m) => Int -> (a -> m b) -> Conduit a m b

Checking whether I can just use this library instead, I noticed that it is not async exception safe:

It uses the plain async function instead of safe functions like withAsync or forConcurrently_, meaning that if an exception comes in at the right time, threads will be leaked.

Just wanted to let you know!

luispedro commented 5 years ago

Thanks for the report.

This is a bona fides bug, but it's not so bad in conduit-algorithms because it uses pure functions, so, worst case is that we waste resources.