MPLLang / mpl

The MaPLe compiler for efficient and scalable parallel functional programming
Other
306 stars 18 forks source link

`callIfIsObjptr` double read #149

Closed shwestrick closed 2 years ago

shwestrick commented 2 years ago

callIfIsObjptr takes an argument objptr *opp, and only calls a closure if isObjptr(*opp). But then the closure is passed opp, and it itself again dereferences *opp. In LC, this is safe due to no concurrent access on the object. In CC, this is unsafe (the value could change due to a concurrent write).

It should be a fairly simple fix. We just need to make sure that the value is read exactly once. Perhaps callIfIsObjptr should be removed, and the closure function should handle that case. Alternatively, we could have the closure take the read value as an additional argument.