[RF] Fix dangling stack normSet after xRooNode::BuildHistogram - #22932
Open
guitargeek wants to merge 2 commits into
Open
[RF] Fix dangling stack normSet after xRooNode::BuildHistogram#22932guitargeek wants to merge 2 commits into
guitargeek wants to merge 2 commits into
Conversation
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.
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.
Test Results 23 files 23 suites 3d 14h 29m 43s ⏱️ For more details on these failures, see this check. Results for commit 79ad705. |
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.
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 oncenormSetgoes 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 guardsRooAbsPdf::_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, beforenormSetis destroyed.Thanks @TomasDado for reporting the problem!
FYI, @will-cern. If this works, I'll also submit it upstream to your xRooFit repo.