Skip to content

websocket: free the Redis context on close instead of disconnecting - #271

Open
SAY-5 wants to merge 1 commit into
nicolasff:masterfrom
SAY-5:ws-free-pending-cmd
Open

websocket: free the Redis context on close instead of disconnecting#271
SAY-5 wants to merge 1 commit into
nicolasff:masterfrom
SAY-5:ws-free-pending-cmd

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 16, 2026

Copy link
Copy Markdown

ws_client_free() calls redisAsyncDisconnect() and then frees ws->cmd, but hiredis defers the disconnect while replies are still pending. When a WebSocket client goes away in the middle of a blocking command (BLPOP, XREADGROUP BLOCK), the reply arrives later and json_reply() runs with the freed cmd as privdata, which is the memmove crash in #270. Using redisAsyncFree() runs the pending callbacks with a NULL reply right away, while ws and cmd are still valid and close_after_events already stops anything from being written.

I could not add an automated test for this since it needs a real Redis with a blocked client; the sequence in the issue (connect via WS, send BLPOP, disconnect, let the timeout expire) is what triggers it.

Fixes #270

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

Segfault disconnecting websocket during XREADGROUP

1 participant