leanprover / leanprover/lean4

Exclusive objects captured in `Task`s should not be marked as multi-threaded

Open
#885 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement low priority P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the implementation of mark_mt and the Task handling for the closure, captured values, and m_value. Trace exclusive and shared paths, then verify that exclusively reachable objects remain unmarked while objects later reached through shared paths are marked, without applying the same assumption to m_value.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.