Bug #17413


[arv-mount] Exit (instead of undefined behavior) after unhandled exception

Added by Tom Clegg over 1 year ago. Updated 12 months ago.

Assigned To:
Target version:
Start date:
Due date:
% Done:


Estimated time:
Story points:


When arv-mount encounters an unhandled exception during a fuse operation, it returns a generic I/O error.

             _logger.exception("Unhandled exception during FUSE operation")
             raise llfuse.FUSEError(errno.EIO)

Since arv-mount uses "finally", function decorators, etc., this should behave correctly in most cases and avoid corrupting internal state.

However, in the case of MemoryError in particular (perhaps others?) it is quite possible for an exception to corrupt internal state, leading to incorrect/unpredictable results and deadlocks when handling concurrent/subsequent fuse operations.

This seems to be an inherent problem with the practice of using exceptions to handle routine errors. It's hard for an outer handler to know the difference between a routine error (passed up the stack gracefully by lower levels after cleaning themselves up with "finally" etc) and a real problem that has already caused the lower levels to abandon all hope of correctness. In the case of MemoryError specifically, which so many innocuous Python statements can encounter, it seems too optimistic to assume that it has been handled correctly by all inner layers without undefined side effects.

If we want to return errors instead of crashing on MemoryError in the most obvious place (i.e., allocating a buffer to read/write Keep data) it would be safer to catch MemoryError at the moment of allocation and re-raise it as a less generic error that can be caught by the generic arv-mount "I/O error" code. That way, when other MemoryError exceptions happen (e.g., while allocating a dict) we can do the safe thing and crash out, rather than proceeding with undefined results.

Actions #2

Updated by Peter Amstutz 12 months ago

  • Target version deleted (To Be Groomed)

Also available in: Atom PDF