Commit 644c7f2
committed
Fix memory corruption in sharded pubsub unsubscribe
This commit fixes two issues in pubsubUnsubscribeChannel that could lead to
memory corruption:
1. The 'found' variable was not initialized to NULL, causing the serverAssert
to potentially pass incorrectly when the hashtable lookup failed, leading
to memory corruption in subsequent operations.
2. When calculating the slot for a channel, we were using getKeySlot() which
might use the current_client's slot if available. This is problematic when
a client kills another client (e.g., via CLIENT KILL command) as the slot
won't match the channel's actual slot.
The fix:
- Initialize 'found' to NULL
- Calculate the slot directly from the channel name using keyHashSlot()
instead of relying on the current client's slot
Added a test case that reproduces the issue by having one client kill another
client that is subscribed to a sharded pubsub channel during a transaction.
Signed-off-by: Uri Yagelnik <[email protected]>1 parent 053bf9e commit 644c7f2
2 files changed
+35
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
345 | 345 | | |
346 | | - | |
| 346 | + | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
56 | 89 | | |
0 commit comments