{{ message }}
fix: keep deferred collection state alive across drops#2934
Open
alexmac wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Change Summary
Bug: deferred export/delete request state stored a raw Collection*. If a chunked export or delete paused, then the collection was dropped before the next chunk, the manager could destroy Collection -> Index -> num_tree_t while the request state still held a dangling pointer. This results in a use-after-free crash on the next deferred chunk when stateful_export_docs or stateful_remove_docs touches the freed Collection, or it could corrupt memory and later show up during Index / num_tree_t destruction like the stack trace.
Fix: export_state_t and deletion_state_t now hold std::shared_ptr in core_api_utils.h (line 10), and the route handlers store the request’s shared pointer in core_api.cpp (line 1489) and core_api.cpp (line 2212). That keeps the collection alive until the deferred request state is destroyed.
PR Checklist