Do not expand function calls when creating DiscontinuityDataEvents to fix bug (crash) #12
+33
−41
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.
When I open SBML file example_crash.xml (generated by example_crash.py) with COPASI and try to run time course, COPASI crashes (and it also crashes on similar files). To fix this, I propose this pull request.
In fact, example_crash.xml contains two functions (
myfun: x -> x + x(important part here is that x appears more than once) andrelu: x -> piecewise(x, x>0, 0)(important that this function creates discontinuity)) and an assignment ruleoutput = myfun(relu(time-0.5)). In the original code, in createDiscontinuityEvents function calls are unrolled becauseCopyBranchwithreplaceDiscontinuousNodes=falsedoes so, so we get something likeoutput = piecewise((time-0.5), (time-0.5)>0, 0) + piecewise((time-0.5), (time-0.5)>0, 0)and create two discontinuities. But when we fill discontinuities in compileObjects it stores arguments of functions, including the case when they are also functions, and in this case it proceedsreluonly once, and fillsmpCalculateof corresponding discontinuity only once. Because of this, at the end we have the second discontinuity withmpCalculateequal toNULL, and when, during time course, we try to call it (in calculateValue), program crashes.I'm not sure that my code is good and COPASI'sh, I'm very open to any suggestions.
Also, my version works with my SBMLs, but I don't understand how to run COPASI tests, maybe you can help with this?