Skip to content

Commit 7a14254

Browse files
committed
Fix pyframe copy
1 parent 3736923 commit 7a14254

13 files changed

Lines changed: 158 additions & 156 deletions

Include/internal/pycore_frame.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ static inline void _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *
153153
int stacktop = (int)(src->stackpointer - src->localsplus);
154154
assert(stacktop >= _PyFrame_GetCode(src)->co_nlocalsplus);
155155
dest->stackpointer = dest->localsplus + stacktop;
156-
for (int i = 1; i < stacktop; i++) {
157-
dest->localsplus[i] = src->localsplus[i];
156+
for (int i = 0; i < stacktop; i++) {
157+
dest->localsplus[i] = _PyStackRef_StealIfUnborrowed(src->localsplus[i]);
158158
}
159159
// Don't leave a dangling pointer to the old frame when creating generators
160160
// and coroutines:

Include/internal/pycore_opcode_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_stackref.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ _PyStackRef_StealIfUnborrowed(_PyStackRef stackref)
225225
return stackref;
226226
}
227227
else {
228-
fprintf(stderr, "===> Converting to strong reference\n");
229228
return (_PyStackRef){ .bits = (uintptr_t)(Py_NewRef(obj)) | Py_TAG_PTR };
230229
}
231230
}

Include/internal/pycore_uop_metadata.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/opcode_ids.h

Lines changed: 64 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/_opcode_metadata.py

Lines changed: 64 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/codeobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
542542
}
543543
co->_co_firsttraceable = entry_point;
544544
#ifdef Py_GIL_DISABLED
545+
// fprintf(stderr, "== Quicken %s\n", PyUnicode_AsUTF8(co->co_qualname));
545546
_PyCode_Quicken(_PyCode_CODE(co), Py_SIZE(co), interp->config.tlbc_enabled);
546547
#else
547548
_PyCode_Quicken(_PyCode_CODE(co), Py_SIZE(co), 1);

Programs/test_frozenmain.h

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ dummy_func(
271271
}
272272

273273
inst (LOAD_FAST_BORROW, (-- value)) {
274-
value = PyStackRef_DupDeferred(value);
274+
value = PyStackRef_DupDeferred(GETLOCAL(oparg));
275275
}
276276

277277
inst(LOAD_FAST_AND_CLEAR, (-- value)) {
@@ -750,7 +750,7 @@ dummy_func(
750750
* only the locals reference, so PyUnicode_Append knows
751751
* that the string is safe to mutate.
752752
*/
753-
assert(Py_REFCNT(left_o) >= 2);
753+
// assert(Py_REFCNT(left_o) >= 2);
754754
PyStackRef_CLOSE_SPECIALIZED(left, _PyUnicode_ExactDealloc);
755755
DEAD(left);
756756
PyObject *temp = PyStackRef_AsPyObjectSteal(*target_local);
@@ -1096,7 +1096,7 @@ dummy_func(
10961096
// is pushed to a different frame, the callers' frame.
10971097
inst(RETURN_VALUE, (retval -- res)) {
10981098
assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
1099-
_PyStackRef temp = retval;
1099+
_PyStackRef temp = _PyStackRef_StealIfUnborrowed(retval);
11001100
DEAD(retval);
11011101
SAVE_STACK();
11021102
assert(EMPTY());

0 commit comments

Comments
 (0)