Skip to content

[6.40] [RF] Don't touch deleted nodes in RooFit::Evaluator destructor - #23911

Merged
guitargeek merged 1 commit into
root-project:v6-40-00-patchesfrom
guitargeek:v640
Oct 30, 2026
Merged

guitargeek merged 1 commit into
root-project:v6-40-00-patchesfrom
guitargeek:v640

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

Backport of #23893.

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
@guitargeek guitargeek self-assigned this Oct 30, 2026
@guitargeek
guitargeek requested a review from bellenot as a code owner October 30, 2026 09:25
@guitargeek guitargeek changed the title [6.42] [RF] Don't touch deleted nodes in RooFit::Evaluator destructor [6.40] [RF] Don't touch deleted nodes in RooFit::Evaluator destructor Oct 30, 2026
@guitargeek
guitargeek merged commit ad851a5 into root-project:v6-40-00-patches Oct 30, 2026
43 checks passed
@guitargeek
guitargeek deleted the v640 branch October 30, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant