Repository navigation
[6.40] [RF] Don't touch deleted nodes in RooFit::Evaluator destructor - #23911
Merged
Merged
Conversation
The Evaluator resets the data tokens of all nodes of its computation graph in the destructor, through raw pointers and without knowing whether the nodes still exist. Nodes that outlive the Evaluator need this reset, because a node can only be registered with one Evaluator at a time. But nodes can also be deleted before the Evaluator: the compiled NLL graph of a RooMomentMorphFuncND references the original morph function and its RooHistPdf templates owned by the RooWorkspace, and at the exit of a Python script the garbage collector can delete the workspace before the NLL object. The destructor then writes into freed memory, which showed up as a `free(): invalid pointer` abort of tutorial-roofit-roofit-rf616_morphing-py in the v6-42-00-rc1 release build on ubuntu2610 (valgrind: "Invalid write of size 8" in RooFit::Evaluator::~Evaluator()). Track the ownership of the data token: RooAbsArg remembers the Evaluator that set its token, tells it in the destructor that the node is gone (Evaluator::unregisterNode), and the Evaluator skips such nodes when resetting the tokens. Add a unit test for the Evaluator that deletes a node before the Evaluator and checks that tokens can be reused in both orders, and a regression test for the workspace-deleted-before-NLL scenario with the morph pdf. This also means we can remove the workarounds in the tutorials introduced by commits 49fb353 and 0687911. 🤖 Done with the help of AI
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.
Backport of #23893.