Skip to content

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

Merged
guitargeek merged 1 commit into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_23893
Oct 30, 2026
Merged

guitargeek merged 1 commit into
root-project:v6-42-00-patchesfrom
root-project-bot:BP_6.42_pull_23893

Conversation

@root-project-bot

Copy link
Copy Markdown

Backport of #23893, requested by @guitargeek.

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

(cherry picked from commit 8242cdc)
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Test Results

    24 files      24 suites   4d 0h 47m 24s ⏱️
 3 905 tests  3 900 ✅ 0 💤 5 ❌
83 615 runs  83 610 ✅ 0 💤 5 ❌

For more details on these failures, see this check.

Results for commit 0380595.

♻️ This comment has been updated with latest results.

@guitargeek guitargeek added this to the 6.42.00 milestone Oct 30, 2026
@guitargeek
guitargeek merged commit 28317a2 into root-project:v6-42-00-patches Oct 30, 2026
71 of 75 checks passed
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.

3 participants