haskell / containers

Assorted concrete container types
https://hackage.haskell.org/package/containers
318 stars 178 forks source link

`Data.Map` memory leaks after an inline #1074

Open nikivazou opened 3 days ago

nikivazou commented 3 days ago

Hey, my program returns within seconds with the below function, but runs forever when the first occurrence of f1' is replaced with the equivalent f1 m.

import qualified Data.Map as M

combine :: (Ord k) => (M.Map k v -> [(k, v)]) -> (M.Map k v -> [(k, v)])
        -> (M.Map k v -> [(k, v)])
combine f1 f2 m =
  let f1' = f1 m
      f2' = f2 (m `M.union` M.fromList f1') -- program does not terminate when f1' is replace with f1 m 
  in f1' ++ f2'

Not sure if this expected or known, but I cannot explain it, so reporting it in case it's worth further investigation.

I am using containers-0.7 and ghc-9.10.1.

(@pacastega)

meooow25 commented 3 days ago

Hi, that is certainly strange, but it's hard to figure something out without knowing the inputs to the function. Do you have a reproducible example?

nikivazou commented 22 hours ago

Let's see if we can reproduce this behavior in a small file. If not, if you are interested, we could give you access to the complete project that has this behavior.