Commit d4266bc6 authored by Xavier Thompson's avatar Xavier Thompson

Fix cypclass arguments of def methods being unlocked when already unlocked

parent c8e408aa
......@@ -3331,7 +3331,7 @@ class DefNode(FuncDefNode):
if not arg.name:
error(arg.pos, "Missing argument name")
if arg.needs_conversion:
arg.entry = env.declare_var(arg.name, arg.type, arg.pos)
arg.entry = env.declare_var(arg.name, arg.type, arg.pos, is_converted_arg = 1)
if arg.type.is_pyobject:
arg.entry.init = "0"
else:
......
......@@ -1970,7 +1970,8 @@ class LocalScope(Scope):
def declare_var(self, name, type, pos,
cname = None, visibility = 'private',
api = 0, in_pxd = 0, is_cdef = 0):
api = 0, in_pxd = 0, is_cdef = 0,
is_converted_arg = 0):
# Add an entry for a local variable.
if visibility in ('public', 'readonly'):
error(pos, "Local variable cannot be declared %s" % visibility)
......@@ -1983,6 +1984,13 @@ class LocalScope(Scope):
entry.in_with_gil_block = self._in_with_gil_block
self.var_entries.append(entry)
# arguments converted as variables should still be locked as arguments
if is_converted_arg and type.is_cyp_class and type.lock_mode != "nolock":
arg_lock_state = self.declare_tracked(entry)
arg_lock_state.is_rlocked = type.is_const
arg_lock_state.is_wlocked = not type.is_const
return entry
def declare_global(self, name, pos):
......
......@@ -367,6 +367,10 @@ void RecursiveUpgradeableRWLock::unlock() {
else if (has_write_lock) {
--my_counts.write_count;
}
else {
fprintf(stderr, "ERROR: trying to unlock already unlocked CyObject !\n");
return;
}
if (!my_counts.write_count && !my_counts.read_count) {
pthread_rwlock_unlock(&this->rw_lock);
my_counts.thread_id = 0;
......
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