Open
Description
The following example will result in a double free:
(defn main []
(let [s @"String"
f (fn [] s)]
(ignore (f))))
The reason is that returning the value s
means the consumer of the lambda will take ownership of it, so when it is done with the value it will call delete
on it, but the value is still captured in the env of the lambda so when the env gets deleted it tries to free something already free-ed.
For the same reason calling a function that take ownership in the lambda will result in the same problem:
(defn main []
(let [s @"String"
f (fn [] (ignore s))]
(f)))