Fix unhandling of possible recursion error on ExceptionRecord.__deepcopy__ - #870
Conversation
xpconanfan
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @uael)
mobly/records.py line 280 at r1 (raw file):
try: exception = copy.deepcopy(self.exception) except (TypeError, RecursionError):
can you share the data that cause this to be raised?
I'm not sure if the same logic is correct for handling RecursionError, so let's take a look at the root cause to be sure
Also, we should have unit tests to cover this case :)
5c82f43 to
da35578
Compare
|
After some more investigation here is what's going on. The AioRpcError from
The
It's raising in the
Even if the recursion is clearly a bug in
I think using the exception as is fine too since it cannot be copied. I also just added a specific unit test. ======================================================================================================================================== FAILURES ========================================================================================================================================
__________________________________________________________________________________________________________________ RecordsTest.test_recursive_exception_record_deepcopy __________________________________________________________________________________________________________________
self = <tests.mobly.records_test.RecordsTest testMethod=test_recursive_exception_record_deepcopy>
def test_recursive_exception_record_deepcopy(self):
"""Makes sure ExceptionRecord wrapper handles deep copy properly in case of recursive exception."""
try:
raise RecordTestRecursiveError()
except RecordTestRecursiveError as e:
er = records.ExceptionRecord(e)
> new_er = copy.deepcopy(er)
tests/mobly/records_test.py:450:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.10/copy.py:153: in deepcopy
y = copier(memo)
mobly/records.py:279: in __deepcopy__
exception = copy.deepcopy(self.exception)
/usr/lib/python3.10/copy.py:172: in deepcopy
y = _reconstruct(x, memo, *rv)
/usr/lib/python3.10/copy.py:265: in _reconstruct
y = func(*args)
/usr/lib/python3.10/copy.py:264: in <genexpr>
args = (deepcopy(arg, memo) for arg in args)
/usr/lib/python3.10/copy.py:172: in deepcopy
y = _reconstruct(x, memo, *rv)
E RecursionError: maximum recursion depth exceeded while calling a Python object
!!! Recursion detected (same locals & position) |
See google/mobly#870 (comment) for more details.
da35578 to
ab738ff
Compare
See google/mobly#870 (comment) for more details.
ab738ff to
2d3bd3d
Compare
uael
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @uael and @xpconanfan)
mobly/records.py line 280 at r1 (raw file):
Previously, xpconanfan (Ang Li) wrote…
can you share the data that cause this to be raised?
I'm not sure if the same logic is correct for handlingRecursionError, so let's take a look at the root cause to be sureAlso, we should have unit tests to cover this case :)
Done.
tests/mobly/records_test.py line 444 at r2 (raw file):
Previously, xpconanfan (Ang Li) wrote…
pls make sure the line stays within line length limit of 80 chars
Done.
See google/mobly#870 (comment) for more details.
See google/mobly#870 (comment) for more details.
While using mobly and aio gRPC, the following very long trace pop on gRPC aio error. Although this might not be Mobly related, since
deepcopycan trigger aRecursionErrorI think it make sense to handle it. This change fix that.Trace (cut for readability):
This change is