Skip to content

fix(when_any): guard stop callback against inline completion destroying the opstate#2115

Open
nebkat wants to merge 1 commit into
NVIDIA:mainfrom
nebkat:fix-when-any-inline-completion
Open

fix(when_any): guard stop callback against inline completion destroying the opstate#2115
nebkat wants to merge 1 commit into
NVIDIA:mainfrom
nebkat:fix-when-any-inline-completion

Conversation

@nebkat

@nebkat nebkat commented Jun 12, 2026

Copy link
Copy Markdown

If every child completes set_stopped() synchronously from inside __stop_source_.request_stop() (senders that complete inline from their stop callbacks), __count_ reaches zero and the receiver is completed -destroying the operation state, including __stop_source_, while request_stop() is still iterating its callback list. The subsequent relock then spins on freed memory.

Adopt __when_all's rug-pull guard: temporarily increment __count_ around request_stop() in the stop callback and arrive afterwards, so completion is deferred until the callback has returned.

https://godbolt.org/z/sPWeEEesE

@copy-pr-bot

copy-pr-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nebkat nebkat changed the title fix(when_any): guard stop callback against inline completion destroyi… fix(when_any): guard stop callback against inline completion destroying the opstate Jun 12, 2026
…ng the opstate

If every child completes set_stopped() synchronously from inside
__stop_source_.request_stop() (senders that complete inline from their
stop callbacks), __count_ reaches zero and the receiver is completed --
destroying the operation state, including __stop_source_, while
request_stop() is still iterating its callback list. The subsequent
relock then spins on freed memory.

Adopt __when_all's rug-pull guard: temporarily increment __count_
around request_stop() in the stop callback and arrive afterwards, so
completion is deferred until the callback has returned.
@nebkat nebkat force-pushed the fix-when-any-inline-completion branch from fc40409 to 1649cf3 Compare June 12, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant