Skip to content

[6.40] [RF] Fix dangling stack normSet after xRooNode::BuildHistogram - #22945

Merged
guitargeek merged 2 commits into
root-project:v6-40-00-patchesfrom
root-project-bot:BP_6.40_pull_22932
Jul 28, 2026
Merged

guitargeek merged 2 commits into
root-project:v6-40-00-patchesfrom
root-project-bot:BP_6.40_pull_22932

Conversation

@root-project-bot

Copy link
Copy Markdown

Backport of #22932, requested by @guitargeek.

Expose setProxyNormSet so that external code can make an object forget a
normalization set previously passed to `getVal()`. This is needed when that
set may not outlive the object (e.g. it lived on the caller's stack), since
the proxies only keep a bare pointer to it. Symmetric to the already-public
`RooAbsPdf::setActiveNormSet`.

🤖 Done with the help of AI.

(cherry picked from commit b0555ea)
BuildHistogram evaluates the model with a stack-local `normSet`. RooFit
proxies only cache a bare pointer to the last normalization set and re-use
it later (e.g. RooProduct::evaluate reads back _compRSet.nset()), so once
`normSet` goes out of scope those proxies dangle into freed stack memory. A
subsequent evaluation then reads it, reported by valgrind as "use of
uninitialised value" in RooAbsReal::getValV (nset->uniqueId()).

`sterilize()` was meant to forget the passed normSet, but in >=6.27 that
code is disabled (the uniqueId invalidity check only guards
`RooAbsPdf::_normSet`, not the proxy pointers) and it only walks
clients, whereas getVal() propagates the normSet down to the servers of
the evaluated function. Reset the proxy normSet on the whole server tree
of every function we called getVal() on, before `normSet` is destroyed.

🤖 Done with the help of AI.

(cherry picked from commit afd1b26)
@guitargeek
guitargeek merged commit 03dfd65 into root-project:v6-40-00-patches Jul 28, 2026
36 of 38 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