Skip to content

fix: release replaced callback captures outside the mutex - #76

Merged
Reddimus merged 1 commit into
mainfrom
fix/callback-capture-lifetime-20261025
Oct 26, 2026
Merged

Reddimus merged 1 commit into
mainfrom
fix/callback-capture-lifetime-20261025

Conversation

@Reddimus

Copy link
Copy Markdown
Owner

Replacing a WebSocket callback could destroy its last captured object while holding the registration mutex. If that object's cleanup registered another callback, the client deadlocked. Swap the callback under the lock and release the old capture after unlocking.

Prepare v0.7.1 and bound individual unit-test runtime. No public API changes.

Validation: the old capture-cleanup probe deadlocked and was terminated after two seconds; the regression passes with the fix. All 335 native and 325 ASan/UBSan CTest entries, 21 ThreadSanitizer WebSocket/callback checks, 75 generator tests, formatting/type/codegen/Markdown checks, and installed/FetchContent consumers pass. Cross-platform CI will validate this commit. No production writes.

@Reddimus
Reddimus force-pushed the fix/callback-capture-lifetime-20261025 branch from e63b721 to 49267d2 Compare October 26, 2026 04:41
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; callback captures are released outside the registration mutex.

Summary

Fixes callback replacement by releasing the old callback’s captures after the registration mutex is unlocked.

  • Replacing a WebSocket callback releases its old captures after unlocking.
  • Callers can create RFQ batches and quote or accept them as a group.
  • HTTP and WebSocket calls apply clearer limits and input checks.
  • WebSocket messages carry more timing and orderbook details.
  • The C++ API and release materials reflect the updated Kalshi endpoints.

Diagram

sequenceDiagram
    participant Caller
    participant Slot as CallbackSlot
    participant Mutex
    participant Capture as Old capture
    Caller->>Slot: set(new callback)
    Slot->>Mutex: lock
    Slot->>Slot: swap callback_ with next
    Slot->>Mutex: unlock
    Slot->>Capture: release old callback
    Capture->>Slot: cleanup may call set again
Loading

Reviews (1) · Last reviewed commit: "fix: release replaced callback captures ..." · Reviewed by Greptile

@Reddimus
Reddimus merged commit cc76571 into main Oct 26, 2026
14 checks passed
@Reddimus
Reddimus deleted the fix/callback-capture-lifetime-20261025 branch October 26, 2026 04:54
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