Details
-
Type:
Bug
-
Status: Done
-
Resolution: Done
-
Fix Version/s: None
-
Component/s: astshim
-
Labels:
-
Story Points:2
-
Epic Link:
-
Team:Alert Production
Description
The current implementation of Mapping::getInverse allocates a new AstMapping, but does not free it if AST's internal error flag triggers an exception via assertOK. In addition, Object::fromAstObject does not free rawObjCopy if there is a dynamic casting error.
The leaks in these methods should be fixed using either assertOK or a catch or finally block. Unfortunately, as I understand it astshim's object and type juggling would interfere with using a unique_ptr.
In addition, both methods should document the exceptions they throw and their (intended) exception safety.
Almost all methods of astshim may throw std::runtime_error if AST reports an error. It is fine to document the most commonly expected errors, but we make promises that those are the only reasons code can throw. If nothing else, it is always possible to call AST code directly and put it into an error state; then the next call to astshim that checks state will throw (not that we expect users to be calling AST code directly). Similarly, if astshim forgets to check in one bit of code then this can manifest as an unexpected error in another bit of code.
I really don't want to clutter up astshim's documentation with "this can throw for any reason" boilerplate. Please keep it small; stick to exceptions that can reasonably be expected. And please do not document "can run out of memory" for a cheap operation like duplicating a transform. Any object creation can run out of memory, but it's not likely and it adds needless clutter to call it out.