Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect assertion in client list operations #1800

Open
wants to merge 5 commits into
base: unstable
Choose a base branch
from

Conversation

uriyage
Copy link
Contributor

@uriyage uriyage commented Feb 27, 2025

The current assertion introduced in redis/redis#11220

serverAssert(&c->clients_pending_write_node.next != NULL || &c->clients_pending_write_node.prev != NULL);

is incorrect for two reasons:

  1. Using &pointer.next would always be non-NULL since it's the address of the field.
  2. The check is incorrect even without the & because in a single-node list, both pointers can be NULL.

Fix:

  1. Remove the always-true assertion
  2. Add proper assertions in listUnlinkNode to ensure the node membership in the list to cover all list cases.

- Fix bug where using &pointer.next would always be non-NULL
- Replace always-true assertion that used &pointer with actual list membership check
- Add proper assertion in listUnlinkNode to ensure list length > 0

Signed-off-by: Uri Yagelnik <[email protected]>
Copy link

codecov bot commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.00%. Comparing base (677d575) to head (35ad39f).
Report is 4 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1800      +/-   ##
============================================
- Coverage     71.17%   71.00%   -0.18%     
============================================
  Files           123      123              
  Lines         65648    65655       +7     
============================================
- Hits          46724    46617     -107     
- Misses        18924    19038     +114     
Files with missing lines Coverage Δ
src/adlist.c 77.50% <100.00%> (+0.57%) ⬆️
src/networking.c 88.77% <ø> (-0.01%) ⬇️

... and 20 files with indirect coverage changes

Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! Small comment though.

uriyage and others added 2 commits February 28, 2025 00:19
Co-authored-by: Viktor Söderqvist <[email protected]>
Signed-off-by: uriyage <[email protected]>
Co-authored-by: Viktor Söderqvist <[email protected]>
Signed-off-by: uriyage <[email protected]>
uriyage added 2 commits March 2, 2025 13:06
Signed-off-by: Uri Yagelnik <[email protected]>
Signed-off-by: Uri Yagelnik <[email protected]>
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.

3 participants