Skip to content

[RF] RooAddPdf: Avoid UB in checkObservables#9557

Merged
guitargeek merged 1 commit intoroot-project:masterfrom
hahnjo:roofit-clang-ub
Jan 13, 2022
Merged

[RF] RooAddPdf: Avoid UB in checkObservables#9557
guitargeek merged 1 commit intoroot-project:masterfrom
hahnjo:roofit-clang-ub

Conversation

@hahnjo
Copy link
Copy Markdown
Member

@hahnjo hahnjo commented Jan 13, 2022

A RooAddPdf may have more PDFs than coefficients, in which case "the coefficient of the last PDF is calculated automatically from the condition that the sum of all coefficients has to be 1". In this case, the last call to _coefList.at(i) is supposed to return
a nullptr because the index is out of range, and dereferencing it is undefined behavior which Clang 13 optimizes away, leading to crashes.

Fixes #9547

A RooAddPdf may have more PDFs than coefficients, in which case
"the coefficient of the last PDF is calculated automatically from
the condition that the sum of all coefficients has to be 1". In
this case, the last call to "_coefList.at(i)" is supposed to return
a nullptr because the index is out of range, and dereferencing it
is undefined behavior which Clang 13 optimizes away, leading to
crashes.

Fixes root-project#9547
@hahnjo hahnjo requested a review from guitargeek January 13, 2022 09:37
@hahnjo hahnjo self-assigned this Jan 13, 2022
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

Copy link
Copy Markdown
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this fix, great job! 👍

From a technical standpoint, this is the right fix to the issue. However, I'm now concerned what the implications are for the functionality that the overlapping observables check is not done for the last pdf. The last coefficient is implicitly defined as one minus the other one, so possibly it's appropriate to check if any observable of the last pdf is overlapping with one of the other coefficients.

Anyway, it's probably a niche problem that I should take care of in another PR when the more urgent developments for 6.26 are completed.

@guitargeek guitargeek merged commit 1f3f0fd into root-project:master Jan 13, 2022
@guitargeek guitargeek added the bug label Jan 13, 2022
@hahnjo hahnjo deleted the roofit-clang-ub branch January 14, 2022 07:55
@guitargeek guitargeek changed the title RooAddPdf: Avoid UB in checkObservables [RF] RooAddPdf: Avoid UB in checkObservables Jan 26, 2022
@phsft-bot
Copy link
Copy Markdown

Starting build on ROOT-debian10-i386/cxx14, ROOT-performance-centos8-multicore/default, ROOT-ubuntu16/nortcxxmod, ROOT-ubuntu2004/soversion, mac1015/python3, mac11/cxx17, windows10/cxx14
How to customize builds

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-ubuntu16/nortcxxmod.
Running on sft-ubuntu-1604-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-26T18:46:44.725Z] CMake Error at /mnt/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-debian10-i386/cxx14.
Running on pcepsft10.dyndns.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-26T19:28:05.639Z] CMake Error at /home/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-performance-centos8-multicore/default.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-26T20:17:52.422Z] CMake Error at /data/sftnight/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

@phsft-bot
Copy link
Copy Markdown

Build failed on mac1015/python3.
Running on macitois21.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-27T00:07:39.088Z] CMake Error at /Volumes/HD2/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

@phsft-bot
Copy link
Copy Markdown

Build failed on windows10/cxx14.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Errors:

  • [2022-01-27T08:24:33.193Z] CMake Error at C:/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

@phsft-bot
Copy link
Copy Markdown

Build failed on mac11/cxx17.
Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-27T12:55:43.824Z] CMake Error at /Users/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

@phsft-bot
Copy link
Copy Markdown

Build failed on ROOT-ubuntu2004/soversion.
Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-01-27T14:26:45.632Z] CMake Error at /home/sftnight/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1064 (message):

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.

[RF] RooFit crashes when ROOT is built with Clang 13

3 participants