Skip to content

Conversation

@enjoy-binbin
Copy link
Contributor

@enjoy-binbin enjoy-binbin commented Feb 7, 2024

After fix for #13033, address sanitizer reports this heap-use-after-free
error. When the pubsubshard_channels dict becomes empty, we will delete
the dict, and the dictReleaseIterator will call dictResetIterator, it
will use the dict so we will trigger the error.

This PR introduced a new struct kvstoreDictIterator to wrap dictIterator.
Replace the original dict iterator with the new kvstore dict iterator.

After fix for redis#13033, address sanitizer reports this heap-use-after-free
error. When the pubsubshard_channels dict becomes empty, we will delete
the dict, and the dictReleaseIterator will call dictResetIterator, it
will use the dict so we will trigger the error.

Instead of releasing the iteraotr via dictReleaseIterator, we release
it via a kvstore wrapper. This PR added a new kvstoreDictReleaseIterator
to handle this.
Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

LGTM.
i have a feeling @guybe7 will have some suggestions.

@guybe7
Copy link
Collaborator

guybe7 commented Feb 7, 2024

i'm thinking of maybe defining a new struct kvstoreDictIterator to wrap dictIterator? it will be cleaner but requires more LOC

@enjoy-binbin
Copy link
Contributor Author

Yes, a new kvstoreDictIterator would be cleaner, that was my first reaction. and after trying this, this one seem not too bad, so i wrote this first.

@oranagra
Copy link
Member

oranagra commented Feb 7, 2024

@guybe7 you're the architect of that project, i'll let you decide.

@guybe7
Copy link
Collaborator

guybe7 commented Feb 7, 2024

ok so let's go with kvstoreDictIterator
@enjoy-binbin do you want to take it?

@enjoy-binbin
Copy link
Contributor Author

yes, i can take it

@enjoy-binbin
Copy link
Contributor Author

@oranagra oranagra merged commit 81666a6 into redis:unstable Feb 7, 2024
@enjoy-binbin enjoy-binbin deleted the fix_use_after_free branch February 8, 2024 07:16
roggervalf pushed a commit to roggervalf/redis that referenced this pull request Feb 11, 2024
…13038)

After fix for redis#13033, address sanitizer reports this heap-use-after-free
error. When the pubsubshard_channels dict becomes empty, we will delete
the dict, and the dictReleaseIterator will call dictResetIterator, it
will use the dict so we will trigger the error.

This PR introduced a new struct kvstoreDictIterator to wrap
dictIterator.
Replace the original dict iterator with the new kvstore dict iterator.

---------

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: guybe7 <guy.benoish@redislabs.com>
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
…13038)

After fix for redis#13033, address sanitizer reports this heap-use-after-free
error. When the pubsubshard_channels dict becomes empty, we will delete
the dict, and the dictReleaseIterator will call dictResetIterator, it
will use the dict so we will trigger the error.

This PR introduced a new struct kvstoreDictIterator to wrap
dictIterator.
Replace the original dict iterator with the new kvstore dict iterator.

---------

Co-authored-by: Oran Agra <oran@redislabs.com>
Co-authored-by: guybe7 <guy.benoish@redislabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants