Automatic detection and masking of non-atomic exception handling