Skip to content

Commit 2f7138b

Browse files
Fix segfault
1 parent bf470bc commit 2f7138b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Python/optimizer.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -798,10 +798,9 @@ translate_bytecode_to_trace(
798798
}
799799
ADD_TO_TRACE(uop, oparg, operand, target);
800800
if (trace_stack[trace_stack_depth].is_dunder_init) {
801-
RESERVE_RAW(3, "_Py_InitCleanup");
801+
RESERVE_RAW(2, "_Py_InitCleanup");
802802
ADD_TO_TRACE(EXIT_INIT_CHECK, 0, 0, target);
803803
ADD_TO_TRACE(RETURN_VALUE, 0, 0, 0);
804-
ADD_TO_TRACE(RESUME_CHECK, 0, 0, 0);
805804
}
806805
DPRINTF(2,
807806
"Returning to %s (%s:%d) at byte offset %d\n",
@@ -856,12 +855,13 @@ translate_bytecode_to_trace(
856855
PyFunctionObject *init_func = (PyFunctionObject *)init;
857856
// Insert a guard that the __init__ is what we expect.
858857
// Then trace through the __init__.
859-
assert(trace[trace_length - 3].opcode == _NOP);
860-
trace[trace_length - 3].opcode = _CHECK_INIT_MATCHES_VERSIONS;
861-
trace[trace_length - 3].operand0 = typ->tp_version_tag;
862-
trace[trace_length - 3].oparg = oparg;
863-
trace[trace_length - 3].target = target;
864-
trace[trace_length - 3].operand1 = init_func->func_version;
858+
_PyUOpInstruction *nop = &trace[trace_length - 3];
859+
assert(nop->opcode == _NOP);
860+
nop->opcode = _CHECK_INIT_MATCHES_VERSIONS;
861+
nop->operand0 = typ->tp_version_tag;
862+
nop->oparg = oparg;
863+
nop->target = target;
864+
nop->operand1 = init_func->func_version;
865865
new_func = init_func;
866866
new_code = (PyCodeObject *)init_func->func_code;
867867
func_version = init_func->func_version;

0 commit comments

Comments
 (0)