Project

General

Profile

Bug #2475

rbd.py can leave Image object in inconsistent state on failure to construct

Added by Dan Mick almost 12 years ago. Updated almost 12 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
librbd
Target version:
% Done:

0%

Source:
Development
Tags:
Backport:
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Pull request ID:
Crash signature (v1):
Crash signature (v2):

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

Revision 8c1c8829 (diff)
Added by Dan Mick almost 12 years ago

rbd.py: Fix seemingly-random segfaults

Avoid resetting Image.closed until image is successfully opened.

Fixes: #2475
Signed-off-by: Dan Mick <>
Reviewed-by: Josh Durgin <>

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.

Also available in: Atom PDF