Commit 714969bc authored by Kevin Modzelewski's avatar Kevin Modzelewski

Refcounting fixes

parent 624173aa
......@@ -308,7 +308,7 @@ void ASTInterpreter::startJITing(CFGBlock* block, int exit_offset) {
code_block = code_blocks[code_blocks.size() - 1].get();
if (!code_block || code_block->shouldCreateNewBlock()) {
code_blocks.push_back(std::unique_ptr<JitCodeBlock>(new JitCodeBlock(autoDecref(source_info->getName())->s())));
code_blocks.push_back(std::unique_ptr<JitCodeBlock>(new JitCodeBlock(source_info->getName()->s())));
code_block = code_blocks[code_blocks.size() - 1].get();
exit_offset = 0;
}
......
......@@ -456,6 +456,7 @@ static int main(int argc, char** argv) noexcept {
} catch (ExcInfo e) {
setCAPIException(e);
PyErr_Print();
PyErr_Clear();
rtncode = 1;
}
} else if (module != NULL) {
......@@ -499,6 +500,7 @@ static int main(int argc, char** argv) noexcept {
} catch (ExcInfo e) {
setCAPIException(e);
PyErr_Print();
PyErr_Clear();
rtncode = 1;
}
}
......
......@@ -150,7 +150,7 @@ extern "C" int PySys_SetObject(const char* name, PyObject* v) noexcept {
return 0;
}
extern "C" PyObject* PySys_GetObject(const char* name) noexcept {
extern "C" BORROWED(PyObject*) PySys_GetObject(const char* name) noexcept {
return sys_module->getattr(autoDecref(internStringMortal(name)));
}
......
......@@ -1858,6 +1858,11 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
if (!rewrite_success)
rewrite_args = NULL;
assert(!oargs);
AUTO_XDECREF(arg1);
AUTO_XDECREF(arg2);
AUTO_XDECREF(arg3);
RewriterVar* r_passthrough = NULL;
if (rewrite_args)
r_passthrough = rewrite_args->rewriter->loadConst((intptr_t)self->passthrough, Location::forArg(0));
......
......@@ -4078,7 +4078,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
AUTO_XDECREF(arg1);
AUTO_XDECREF(arg2);
AUTO_XDECREF(arg3);
AUTO_XDECREF_ARRAY(args, num_output_args - 3);
AUTO_XDECREF_ARRAY(oargs, num_output_args - 3);
if (rewrite_args && !rewrite_success) {
assert(0 && "check refcounting");
......
......@@ -364,7 +364,7 @@ BoxedFunction::BoxedFunction(FunctionMetadata* md, std::initializer_list<Box*> d
// we don't have yet.
if (md->source) {
assert(!this->name);
this->name = static_cast<BoxedString*>(md->source->getName());
this->name = incref(static_cast<BoxedString*>(md->source->getName()));
}
}
......
# Random regression test from implementing refcounting:
def f():
f.x = f
f()
f()
f()
f()
f()
f()
f()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment