๐๏ธ Restore macOS security-scoped bookmarks - #625
Conversation
โฆcurity-scoped-bookmarks
There was a problem hiding this comment.
๐ก Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d0fdbe8de3
โน๏ธ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with ๐.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| fun start(): Boolean { | ||
| check(!released) { "This security-scoped bookmark has been released" } | ||
| val granted = requireNotNull(scopeUrl).startAccessingSecurityScopedResource() | ||
| if (granted) { | ||
| activeAccesses += 1 |
There was a problem hiding this comment.
Serialize access to the shared native bookmark lease
When multiple threads operate on files derived from the same Kotlin/Native macOS bookmark, start(), stop(), and release() concurrently mutate released, activeAccesses, and scopeUrl without synchronization. For example, release() can observe zero active accesses and clear scopeUrl after start() passes its check but before it increments the counter, causing the subsequent stop() to throw and leave the native scope unbalanced; two simultaneous closes can likewise decrement the counter twice. The corresponding JVM implementation synchronizes these transitions, so the native lease needs equivalent serialization.
AGENTS.md reference: AGENTS.md:L12-L12
Useful? React with ๐ย / ๐.
Closes #590
Summary
Validation