Skip to content

🐛 fix(soft-rw): isolate async lock workers - #1037

Closed
gaborbernat wants to merge 1 commit into
tox-dev:mainfrom
gaborbernat:fix/soft-rw-executor-isolation
Closed

gaborbernat wants to merge 1 commit into
tox-dev:mainfrom
gaborbernat:fix/soft-rw-executor-isolation

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

With executor=None, AsyncSoftReadWriteLock used the event loop's default executor. A blocked wait could occupy that shared pool and delay the release of an unrelated lock. Each default wrapper now owns a worker, so its wait cannot consume another wrapper's release capacity. This addresses draft advisory ANT-2026-O69ASZD0.

Shared executor stalled unrelated releases

The old submission path passed None to loop.run_in_executor. A waiting lock could fill the loop's default pool before a different lock submitted its release. The new default assigns one worker to each wrapper. close() requests shutdown without depending on the loop's default executor.

sequenceDiagram
    participant A as Waiting lock
    participant E as Loop default worker
    participant B as Unrelated lock
    rect rgb(255, 226, 226)
        A->>+E: wait for lock
        B->>E: queue release
        Note over E,B: release waits for the worker
        E-->>-A: wait ends
        E-->>B: release runs
    end
    participant W as Waiting lock worker
    participant R as Release lock worker
    rect rgb(226, 245, 226)
        A->>+W: wait for lock
        B->>+R: release
        R-->>-B: release completes
        W-->>-A: wait ends
    end
Loading

Behavior changes

The default creates a worker thread on its first backend call and requests its shutdown on close() or collection. A caller-supplied executor remains caller-owned and must have capacity for releases while other calls wait in that pool. The change does not isolate separate wrappers that share the same caller-supplied executor.

Reported by OSS Scanner: ANT-2026-O69ASZD0.

A wait on one async soft read/write lock could occupy the event loop's
default pool while another lock's release remained queued. Give each
default wrapper an owned worker so the blocked wait cannot delay that
release.

Caller-supplied executors remain caller-owned and need enough capacity
for concurrent waits and releases.
@gaborbernat gaborbernat added bug security Fixes a published or draft security advisory labels Nov 20, 2026
@gaborbernat
gaborbernat marked this pull request as draft November 20, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug security Fixes a published or draft security advisory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant