Bug #2475
rbd.py can leave Image object in inconsistent state on failure to construct
Description
Constructing an Image object with bad parameters (say, an nonexistent rbd image name) can leave the
resulting object in an inconsistent state, such that later operations (even unconnected to the
failed Image object) can cause python to segfault.
I think this is due to a bug in Image.__init__, in that it sets self.closed to False before successfully
completing the 'check for string' and rbd_open() operations; this means that anything that calls the
Image.close() will attempt to call rbd_close() with, probably, a NULL pointer. This includes del, which
is probably called on the next Python statement after the failed Image.__init__, leading to the
weird failure.
Associated revisions
rbd.py: Fix seemingly-random segfaults
Avoid resetting Image.closed until image is successfully opened.
Fixes: #2475
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
History
#1 Updated by Dan Mick almost 12 years ago
- Status changed from New to Resolved
#2 Updated by Dan Mick almost 12 years ago
In the interactive interpreter, "the next statement" is where the interpreter knows the prior scope is closed, and destroys the object then, I'm guessing.