Skip to content

Fix unexpected subscription confirmations crashing async clients - #1396

Open
Artyx71 wants to merge 1 commit into
redis:masterfrom
Artyx71:fix/unexpected-subscribe-reply
Open

Artyx71 wants to merge 1 commit into
redis:masterfrom
Artyx71:fix/unexpected-subscribe-reply

Conversation

@Artyx71

@Artyx71 Artyx71 commented Nov 10, 2026 •

Copy link
Copy Markdown

Fixes #1393.

An unexpected subscribe or psubscribe confirmation for an unregistered channel aborts an assertion-enabled client and dereferences a null callback in release builds. Decrement the pending counter only when a callback was found. Unknown confirmations then follow the existing unmatched-reply handling, while registered subscriptions continue to receive their callbacks.

Add eight checks covering unknown and expected confirmations for channels and patterns in RESP2 and RESP3. They reproduce the assertion failure on unchanged upstream; an independent release build with NDEBUG also reproduces the null access under ASan/UBSan. The fixed release build passes all eight checks under both sanitizers.

Validation: warning-free Make and CMake builds; full TLS/async test run against Redis 7.4: 233 passed, 0 skipped.


Note

Low Risk
Narrow guard around pub/sub bookkeeping; registered subscriptions behave as before, with regression tests added.

Overview
Fixes a crash when the async client receives a subscribe or psubscribe confirmation for a channel or pattern that has no registered callback. __redisGetSubscribeCallback in async.c now decrements pending_subs only when a matching callback exists, so stray confirmations are dropped like other unmatched pub/sub replies instead of tripping an assertion or null-dereferencing in release builds.

Adds test_unexpected_subscribe_replies in test.c with eight synthetic RESP2/RESP3 checks (channel and pattern, unknown vs known) to lock in the ignore and callback paths.

Reviewed by Cursor Bugbot for commit b26e460. Bugbot is set up for automated code reviews on this repo. Configure here.

Only decrement pending subscriptions when the confirmation matches a
registered callback. Ignore unknown confirmations through the existing
unmatched-reply path, preserving handling of legitimate subscriptions.

Cover channels and patterns in RESP2 and RESP3 with reader-fed tests.

Fixes redis#1393
@github-actions github-actions Bot added the bug label Nov 10, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T15:15:08.628379Z b26e460 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

__redisGetSubscribeCallback: NULL pointer dereference on unexpected "subscribe" push reply (assert compiled out under NDEBUG)

1 participant