-
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] HistFactory PreprocessFunction::PrintXML() needs to escape special characters to produce valid XML #10840
Comments
Some improvements are made to the `PreprocessFunction` class: * add `const` to all the relevant member functions * remove the `fCommand` member, because it can be inferred from the other 3 members and it should not be set independently * use `std::string` by const-reference when possible * follow the RooFit coding style of using lower-case vor function argument names Furthermore, a bugfix is also done: * in `PreprocessFunction::PrintXML`, replace the XML special characters which almost always appear in any formula with the XML escape codes The bugfix addresses a problem where it was not possible to read an XML generated by `Measurement::PrintXML` because the special characters in the formula expression were not properly escaped. With all these changes applied, the source files for this class changed almost completely, and this opportunity was taken to reformat the code with the ROOT `clang-format` style. Closes root-project#10840.
Hi @TomasDado, thanks for opening this issue! Indeed, it's not good that you get broken XML code when you print the XML for a measurement with a preprocessing function. I have opened a PR to fix this, and also changed the title to describe the issue more accurately (also removing the The patch should make it in the next 6.26.06 patch release, which I hope will help you with your workflows! Then the right way to proceed for you will be to use the escape characters only when you write XML by hand, and in |
Hi @guitargeek, Thank you very much for updating the code! Just for my understanding, do the changes also fix the seg fault in |
Hi! I could not reproduce the segfault. I think it already got reported by somebody else and fixed by this PR: To confirm this, it would be helpful if you'd source one of the ROOT nightlies on lxplus and check if the segfault is gone. |
Hi, I tested the code with the current master branch and I can confirm the crash is fixed. Thanks a lot! |
Great, thanks for checking! |
Some improvements are made to the `PreprocessFunction` class: * add `const` to all the relevant member functions * remove the `fCommand` member, because it can be inferred from the other 3 members and it should not be set independently * use `std::string` by const-reference when possible * follow the RooFit coding style of using lower-case vor function argument names Furthermore, a bugfix is also done: * in `PreprocessFunction::PrintXML`, replace the XML special characters which almost always appear in any formula with the XML escape codes The bugfix addresses a problem where it was not possible to read an XML generated by `Measurement::PrintXML` because the special characters in the formula expression were not properly escaped. With all these changes applied, the source files for this class changed almost completely, and this opportunity was taken to reformat the code with the ROOT `clang-format` style. Closes #10840.
Some improvements are made to the `PreprocessFunction` class: * add `const` to all the relevant member functions * remove the `fCommand` member, because it can be inferred from the other 3 members and it should not be set independently * use `std::string` by const-reference when possible * follow the RooFit coding style of using lower-case vor function argument names Furthermore, a bugfix is also done: * in `PreprocessFunction::PrintXML`, replace the XML special characters which almost always appear in any formula with the XML escape codes The bugfix addresses a problem where it was not possible to read an XML generated by `Measurement::PrintXML` because the special characters in the formula expression were not properly escaped. With all these changes applied, the source files for this class changed almost completely, and this opportunity was taken to reformat the code with the ROOT `clang-format` style. Closes root-project#10840.
Some improvements are made to the `PreprocessFunction` class: * add `const` to all the relevant member functions * remove the `fCommand` member, because it can be inferred from the other 3 members and it should not be set independently * use `std::string` by const-reference when possible * follow the RooFit coding style of using lower-case vor function argument names Furthermore, a bugfix is also done: * in `PreprocessFunction::PrintXML`, replace the XML special characters which almost always appear in any formula with the XML escape codes The bugfix addresses a problem where it was not possible to read an XML generated by `Measurement::PrintXML` because the special characters in the formula expression were not properly escaped. With all these changes applied, the source files for this class changed almost completely, and this opportunity was taken to reformat the code with the ROOT `clang-format` style. Closes #10840.
Some improvements are made to the `PreprocessFunction` class: * add `const` to all the relevant member functions * remove the `fCommand` member, because it can be inferred from the other 3 members and it should not be set independently * use `std::string` by const-reference when possible * follow the RooFit coding style of using lower-case vor function argument names Furthermore, a bugfix is also done: * in `PreprocessFunction::PrintXML`, replace the XML special characters which almost always appear in any formula with the XML escape codes The bugfix addresses a problem where it was not possible to read an XML generated by `Measurement::PrintXML` because the special characters in the formula expression were not properly escaped. With all these changes applied, the source files for this class changed almost completely, and this opportunity was taken to reformat the code with the ROOT `clang-format` style. Closes root-project#10840.
Some improvements are made to the `PreprocessFunction` class: * add `const` to all the relevant member functions * remove the `fCommand` member, because it can be inferred from the other 3 members and it should not be set independently * use `std::string` by const-reference when possible * follow the RooFit coding style of using lower-case vor function argument names Furthermore, a bugfix is also done: * in `PreprocessFunction::PrintXML`, replace the XML special characters which almost always appear in any formula with the XML escape codes The bugfix addresses a problem where it was not possible to read an XML generated by `Measurement::PrintXML` because the special characters in the formula expression were not properly escaped. With all these changes applied, the source files for this class changed almost completely, and this opportunity was taken to reformat the code with the ROOT `clang-format` style. Closes root-project#10840.
Describe the bug
Calling RooStats::HistFactory::MakeModelAndMeasurementFast(meas) leads to a seg violation in root 6.26.04 with gcc11 on CentOS7 machine (lxplus), while the same code worked with 6.24.06 with gcc8 on CentOS7 machine.
This is the relevant stack trace:
Note that this happens only for some setups, so I tried to debug it a bit and see what is special about the setups that crash. I will briefly describe what I found out:
We use AddPreprocessFunction() method to reparametrise our likelihood, this generally seems to work, but for some special cases this seems to cause problems. I created the XML files for the problematic setups and tried to use
hist2workspace
to try to identify the issues. I found out that the executable cannot read the XML files produced if it contains&
and<
or>
as these are not valid XML characters and need to be escaped. So e.g. if the top level XML contains function like this:The
hist2workspace
executable will complain that it cannot parse the XML. I tried replacing the problematic characters with the XML replacements like>
etc. This makes thehist2workspace
code run and it generates the workspace. However, if I try to replace the characters in the same way for the string passed to AddPrepropcessFunction, it doesnt parse the string and complains:I am not 100% sure these two issue - crash in the
MakeModelAndMeasurementFast
code and the XML parsing are related, but I think they could be.Expected behavior
The code should not crash when calling
MakeModelAndMeasurementFast
as was the case in ROOT 6.24.06. The XML generated should be a valid XML that can be processed with histo2workspace.To Reproduce
Adding any Expression to the top level XML file that contains characters like
&
,<
breaks histo2workpace and it seems that using formuale containing these characters inAddPrepropcessFunction
crashesMakeModelAndMeasurementFast
.Setup
The text was updated successfully, but these errors were encountered: