From cbdbd854daae62d9c7b59b225c513d08124f7d34 Mon Sep 17 00:00:00 2001 From: Carl Friedrich Bolz-Tereick Date: Fri, 19 Feb 2021 17:34:42 +0100 Subject: workaround for a crash when running test_recursive_pickle in test_functools on the py3.7 branch The test produces stack overflows intentionally, and if we blackhole at the wrong stack depth then an vmprof frame is not popped correctly for some reason. unfortunately I was not able to find the reason, but this mitigation at least prevents the vm from crashing. --- rpython/rlib/rvmprof/cintf.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py index c63e12d120..b8e9492789 100644 --- a/rpython/rlib/rvmprof/cintf.py +++ b/rpython/rlib/rvmprof/cintf.py @@ -229,8 +229,25 @@ def jit_rvmprof_code(leaving, unique_id): enter_code(unique_id) # ignore the return value else: s = vmprof_tl_stack.getraw() - assert s.c_value == unique_id and s.c_kind == VMPROF_CODE_TAG - leave_code(s) + if s.c_value == unique_id and s.c_kind == VMPROF_CODE_TAG: + leave_code(s) + else: + # this is a HACK! in some strange situations related to stack + # overflows we end up in a situation where the stack is not + # properly popped somewhere, so we end up with an extra entry. + # instead of crashing with an assertion error (which was done + # previously) try to fix the situation by popping of the stack + # twice. if that also gives the wrong unique_id we still crash with + # an assert. + + # the test that found this problem is test_recursive_pickle in + # python3 test_functools.py + assert (s.c_next and s.c_next.c_value == unique_id and + s.c_next.c_kind == VMPROF_CODE_TAG) + s = vmprof_tl_stack.getraw() + leave_code(s) + s = vmprof_tl_stack.getraw() + leave_code(s) # # traceback support -- cgit v1.2.3-65-gdbad