Uninitialized jump in render's Transformation2D::readAttributes
Running stuff through valgrind, I came across the error:
==4973== Conditional jump or move depends on uninitialised value(s)
==4973== at 0xD75631: libsbml::Transformation2D::readAttributes(libsbml::XMLAttributes const&, libsbml::ExpectedAttributes const&) (Transformation2D.cpp:725)
==4973== by 0xD2454F: libsbml::GraphicalPrimitive1D::readAttributes(libsbml::XMLAttributes const&, libsbml::ExpectedAttributes const&) (GraphicalPrimitive1D.cpp:1123)
==4973== by 0xD2879D: libsbml::GraphicalPrimitive2D::readAttributes(libsbml::XMLAttributes const&, libsbml::ExpectedAttributes const&) (GraphicalPrimitive2D.cpp:858)
==4973== by 0xD5DCB3: libsbml::RenderGroup::readAttributes(libsbml::XMLAttributes const&, libsbml::ExpectedAttributes const&) (RenderGroup.cpp:2253)
==4973== by 0xB646A3: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4467)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
==4973== by 0xB65013: libsbml::SBase::read(libsbml::XMLInputStream&) (SBase.cpp:4606)
Investigating, my guess is that this is because the parent of the Transformation2D is always cast to a 'ListOfDrawables', which it absolutely does not have to be: there are several different types of objects that Transformation2D objects can be the children of. In one file I read, here are all the different types:
- ListOfLineEndings, which claims to be the type SBML_LIST_OF
- LineEnding (SBML_RENDER_LINEENDING) (doesn't inherit from ListOf)
- RenderGroup (SBML_RENDER_GROUP) (also not a ListOf)
- GlobalStyle (SBML_RENDER_GLOBALSTYLE) (also not a ListOf, nor does it inherit from the LineEnding/RenderGroup base classes)
None of those are ListOfDrawables!
The code seems to want to change 'UnknownPackageAttribute' and 'UnknownCoreAttribute' errors to Render-specific errors. Do we need to do this for all the different Things That The Parent Might Be?
See https://github.com/sbmlteam/libsbml/commit/b22583ea59f4c5f216d09d3064e1e6db61b27a2a for an attempt to fix this. Mostly I'm not entirely sure what situation causes the errors to show up in the log like that, when they need to be moved.