This commit is contained in:
blueloveTH 2025-08-25 20:16:11 +08:00
parent a55f62c860
commit 0ce88fa70c
3 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#include "pocketpy/interpreter/vm.h"
#include "pocketpy/common/sstream.h"
#include "pocketpy/objects/codeobject.h"
#include "pocketpy/objects/exception.h"
#include "pocketpy/pocketpy.h"
#include "pocketpy/objects/error.h"
#include <stdbool.h>
@ -820,7 +821,8 @@ __NEXT_STEP:
return RES_YIELD;
} else {
assert(self->last_retval.type == tp_StopIteration);
py_ObjectRef value = py_getslot(&self->last_retval, 0);
BaseException* ud = py_touserdata(py_retval());
py_ObjectRef value = &ud->args;
if(py_isnil(value)) value = py_None();
*TOP() = *value; // [iter] -> [retval]
DISPATCH_JUMP((int16_t)byte.arg);

View File

@ -635,7 +635,9 @@ void ManagedHeap__mark(ManagedHeap* self) {
assert(p_stack->length == 0);
// mark value stack
for(py_TValue* p = vm->stack.begin; p != vm->stack.end; p++) {
for(py_TValue* p = vm->stack.begin; p < vm->stack.sp; p++) {
// assert(p->type != tp_nil);
if(py_isnil(p)) continue;
pk__mark_value(p);
}
// mark modules

9
tests/71_gc_bug.py Normal file
View File

@ -0,0 +1,9 @@
a=[]
import gc
gc.collect()
# a.append(a)
print(list(globals().items()))
del a
print(list(globals().items()))
gc.collect()