-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RF] RooCmdArg pythonization drops temporary RooArgSets too early #11421
Comments
Hi, thanks for reporting this and trying out the new pythonizations! I guess you also know about This RooArgSet issue is known, I just didn't fix it for all the command arguments yet. But I will do it know. Since you seem to be a RooFit power use I wanted to ask you: do you have any suggestions for further Pythonizations or PyROOT-exclusive RooFit features? |
As reported in issue root-project#11421, the fact that in the RooFit command arguments, the `RooArgSet`s are often stored by pointer is still a problem. I attempted before to circumvent the problem by detecting potential lifetime issues by having a dedicated `RooArgSet&&` overloads that resulted in RooCmdArgs that owned copied of the RooArgSets. However, this still didn't work for the case where the Python collection pythonizations are used in PyROOT, because there the `RooArgSet &&` overloads are not hit. I realized now that the `RooCmdArg` class already has the slots to store RooArgSets by value, which was alredy used by a few RooFit command arguments. When these `set` slots are used, there are no ownership issues. This commit suggests to always use these `set` slots for RooArgSets. This entailed changing the functions that make use of the command arguments, migrating from `defineObject` to `defineSet`. All the hacks to get owned copies of the RooArgSets and `RooArgSet&&` overloads can now be removed. Now that the slot indices for the sets was changed in many RooFit command arguments, there is only the caveat that command arguments are not backwards compatible anymore. However, this should not be any problem because `RooCmdArgs` are not supposed to be written to files anyway. To explicitely disallow this and prevent any silet backwards compatibility issue, the class version of the RooCmdArg was set to zero to disable IO. Closes root-project#11421.
As reported in issue root-project#11421, the fact that in the RooFit command arguments, the `RooArgSet`s are often stored by pointer is still a problem. I attempted before to circumvent the problem by detecting potential lifetime issues by having a dedicated `RooArgSet&&` overloads that resulted in RooCmdArgs that owned copied of the RooArgSets. However, this still didn't work for the case where the Python collection pythonizations are used in PyROOT, because there the `RooArgSet &&` overloads are not hit. I realized now that the `RooCmdArg` class already has the slots to store RooArgSets by value, which was alredy used by a few RooFit command arguments. When these `set` slots are used, there are no ownership issues. This commit suggests to always use these `set` slots for RooArgSets. This entailed changing the functions that make use of the command arguments, migrating from `defineObject` to `defineSet`. All the hacks to get owned copies of the RooArgSets and `RooArgSet&&` overloads can now be removed. Now that the slot indices for the sets was changed in many RooFit command arguments, there is only the caveat that command arguments are not backwards compatible anymore. However, this should not be any problem because `RooCmdArgs` are not supposed to be written to files anyway. To explicitely disallow this and prevent any silet backwards compatibility issue, the class version of the RooCmdArg was set to zero to disable IO. Closes root-project#11421.
Hi, I thought this had been fixed with the addition of I know about the numpy/pandas conversion, but I have not tried them yet as my analysis is TTree based. From my experience now:
|
Thanks a lot for your comment!
Yes, I would like this too, but it's technically not easy to implement without changing the source for all PDFs. Maybe I will have an idea at some point as I learn more about PyROOT, but for now I have none
That's a very good idea!
That's a pretty good idea too. I guess one can simply create new Python references to each server that are set as an attribute of the server, such that they are always kept alive. But you're right, server redirection would break this, unless there are Pythonizations for that one too.... So I still need to think if this is worth it, also considering that users can also use the RooWorkspace factory interface to create PDFs, which doesn't have this problem. |
As reported in issue #11421, the fact that in the RooFit command arguments, the `RooArgSet`s are often stored by pointer is still a problem. I attempted before to circumvent the problem by detecting potential lifetime issues by having a dedicated `RooArgSet&&` overloads that resulted in RooCmdArgs that owned copied of the RooArgSets. However, this still didn't work for the case where the Python collection pythonizations are used in PyROOT, because there the `RooArgSet &&` overloads are not hit. I realized now that the `RooCmdArg` class already has the slots to store RooArgSets by value, which was alredy used by a few RooFit command arguments. When these `set` slots are used, there are no ownership issues. This commit suggests to always use these `set` slots for RooArgSets. This entailed changing the functions that make use of the command arguments, migrating from `defineObject` to `defineSet`. All the hacks to get owned copies of the RooArgSets and `RooArgSet&&` overloads can now be removed. Now that the slot indices for the sets was changed in many RooFit command arguments, there is only the caveat that command arguments are not backwards compatible anymore. However, this should not be any problem because `RooCmdArgs` are not supposed to be written to files anyway. To explicitely disallow this and prevent any silet backwards compatibility issue, the class version of the RooCmdArg was set to zero to disable IO. Closes #11421.
As reported in issue root-project#11421, the fact that in the RooFit command arguments, the `RooArgSet`s are often stored by pointer is still a problem. I attempted before to circumvent the problem by detecting potential lifetime issues by having a dedicated `RooArgSet&&` overloads that resulted in RooCmdArgs that owned copied of the RooArgSets. However, this still didn't work for the case where the Python collection pythonizations are used in PyROOT, because there the `RooArgSet &&` overloads are not hit. I realized now that the `RooCmdArg` class already has the slots to store RooArgSets by value, which was alredy used by a few RooFit command arguments. When these `set` slots are used, there are no ownership issues. This commit suggests to always use these `set` slots for RooArgSets. This entailed changing the functions that make use of the command arguments, migrating from `defineObject` to `defineSet`. All the hacks to get owned copies of the RooArgSets and `RooArgSet&&` overloads can now be removed. Now that the slot indices for the sets was changed in many RooFit command arguments, there is only the caveat that command arguments are not backwards compatible anymore. However, this should not be any problem because `RooCmdArgs` are not supposed to be written to files anyway. To explicitely disallow this and prevent any silet backwards compatibility issue, the class version of the RooCmdArg was set to zero to disable IO. Closes root-project#11421.
Describe the bug
When using the pythonization of some
RooCmdArgs
together with theRooArgSet
pythonization, the created set is dropped too early.It does not always cause a segfault (depends on the
RooCmdArg
) but it is visible invalgrind
.I've seen this happen with
Minos
,Slice
,Project
,Parameters
and SelectVar, while I testedConditional
,Constrain
,ExternalConstraints
,Components
andVisualizeError
and they show no issue (not even invalgrind
).I think the difference is wether the
RooArgSet
is stored as aRooArgSet
in theRooCmdArg
(works fine) or as aTObject*
(dropped early).I've also noticed that this happens only when you combine the two pythonizations, e.g. both
work fine, only
is affected.
Expected behavior
No use after free
To Reproduce
Setup
ROOT 6.26.07 from LCG dev4
ROOT master from LCG dev3
Additional context
The text was updated successfully, but these errors were encountered: