lean4
lean4 copied to clipboard
Exclusive objects captured in `Task`s should not be marked as multi-threaded
This is another unexpected RC operation I noticed while debugging the recent lsan false positive. If their RC is 1, neither the task closure nor its captured values should be marked as multi-threaded. More specifically, any object reachable only through an "exclusive path" should no be marked, so we would need a modified mark_mt. Note that there could be a chance of visiting objects twice in this marking if we first find them via an exclusive path and later through a shared path (at which point we would mark them MT, so we would not visit them a third time).
Unfortunately, I don't see a way to do the same for the task output, i.e. m_value. Even if the task object is ST and exclusive, we set the field from another thread, so we might be racing with a inc_ref or mark_mt on the thread owning the task object.