cellml / libcellml

Repository for libCellML development.
https://libcellml.org
Apache License 2.0
16 stars 21 forks source link

Fix segfault when printing complete MathML document #1026

Closed hsorby closed 2 years ago

hsorby commented 2 years ago

Fixes #1024.

hsorby commented 2 years ago

It appears some OSes give you a segfault and others will return an empty string, both outcomes are undesirable.

nickerso commented 2 years ago

So this PR solves this issue by picking up on any errors when using libXml2 to parse the generated model to "pretty print" the serialised model - which is a good addition. But since we already have an internal printMath function in the printer to process the math strings I wonder if we should be using that to remove XML declarations? Seems like it might be a fairly common use-case to use an external library like libSBML to generate MathML to put into components and those fragments may be complete self-contained XML documents.

But perhaps this is really a future addition to that "model fixer" tool that we have previously discussed...

hsorby commented 2 years ago

I have re-jigged the logging of errors to include the location (reset, or component) where the MathML error was detected. I think this makes more sense when the MathML is subsequently not printed but the rest of the model is.