Commit 013eec6b authored by Xavier Thompson's avatar Xavier Thompson

Fix reference counting in cypclass locks

parent 2fd7bc9f
......@@ -14329,9 +14329,8 @@ class CoerceToLockedNode(CoercionNode):
def generate_disposal_code(self, code):
# Close the scope to release the lock.
code.putln("}")
# Dispose of and free subexpressions.
self.arg.generate_subexpr_disposal_code(code)
self.arg.free_subexpr_temps(code)
# Dispose of the temporary without decrefing.
self.arg.generate_post_assignment_code(code)
class CoerceToArgAssmtNode(CoercionNode):
......
......@@ -8630,7 +8630,8 @@ class LockCypclassNode(StatNode):
self.obj.analyse_declarations(env)
def analyse_expressions(self, env):
self.obj = obj = self.obj.analyse_types(env)
obj = self.obj.analyse_types(env)
self.obj = obj.coerce_to_temp(env)
self.body = self.body.analyse_expressions(env)
if not obj.type.is_cyp_class:
error(obj.pos, "Locking non-cypclass reference")
......@@ -8666,6 +8667,11 @@ class LockCypclassNode(StatNode):
# Close the scope to release the lock.
code.putln("}")
# Dispose of the temporary without decrefing.
self.obj.generate_post_assignment_code(code)
# Free the temporary.
self.obj.free_temps(code)
def cython_view_utility_code():
from . import MemoryView
......
......@@ -320,6 +320,7 @@
~Cy_rlock_guard() {
if (this->o != NULL) {
this->o->CyObject_UNRLOCK();
this->o->CyObject_DECREF();
}
else {
fprintf(stderr, "ERROR: trying to unrlock NULL !\n");
......@@ -341,6 +342,7 @@
~Cy_wlock_guard() {
if (this->o != NULL) {
this->o->CyObject_UNWLOCK();
this->o->CyObject_DECREF();
}
else {
fprintf(stderr, "ERROR: trying to unwlock NULL !\n");
......
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