Closed avandecreme closed 1 year ago
Thanks for the report. Yes I need to think about this - there are other places where functions like this will recurse down the whole tree but I need to look at this before I'm convinced this is the right approach here
I can see exactly where this is happening but it will only happen when a model has been converted but then fails validation. Do you happen to have a small example which will save me trying to find one? Thanks
Sorry I've just spotted it
The following program seg fault when run with the following uncompressed file.
Result in:
I tracked down the issue to the fact when failing to do a strict conversion, we restore the model of the document to a stored copy here: https://github.com/sbmlteam/libsbml/blob/49ce5b40ead6862c1a610a569d0606f03a4fb4fa/src/sbml/conversion/SBMLLevelVersionConverter.cpp#L424
However, copying a model does not copy the
mSBML
field onSBase
: https://github.com/sbmlteam/libsbml/blob/49ce5b40ead6862c1a610a569d0606f03a4fb4fa/src/sbml/SBase.cpp#L421 This is put in evidence by theParent doc is null
outputs above.This then cause the crash when running the consistency check on unique ids because the following line trust that
m.getSBMLDocument()
will return a non null value: https://github.com/sbmlteam/libsbml/blob/49ce5b40ead6862c1a610a569d0606f03a4fb4fa/src/sbml/validator/constraints/UniqueIdsInModel.cpp#L166I am able to fix that specific issue by adding the following line when cloning the model in the
SBMLLevelVersionConverter
:However, I am not sure this is the best approach because all other
SBase
(reactions, compartments...) of the model will still be missing there back link to the document.Any idea how to best fix this?