fix: make `lean_mark_persistent` safe for objects used by other threads This PR fixes a race in `Runtime.markPersistent` on objects that other threads are using, which could revive such an object with a wrong reference count and lead to a use after free. `lean_mark_persistent` wrote a zero count into thread-shared objects with a plain store. A reference count adjustment that another thread had in flight then landed on top of the zero. For a thread-shared object it now atomically stores a count from the middle of the sticky range, where adjustments in flight cannot move it back out; such an object is never freed and its count is no longer adjusted, but it is not reported by `lean_is_persistent`. Objects owned by the current thread still get a zero count. The interpreter's symbol cache, which relied on persistent names having stable addresses, accepts all never-freed names. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This is the repository for Lean 4.
See Install Lean.
Please read our Contribution Guidelines first.
See Building Lean.