* libguile/procprop.c (scm_set_procedure_property_x): Block system
asyncs while overrides_lock is held. Use dynwind block in case
an exception is thrown.
SCM_MISC_ERROR ("arity is a deprecated read-only property", SCM_EOL);
#endif
SCM_MISC_ERROR ("arity is a deprecated read-only property", SCM_EOL);
#endif
- scm_i_pthread_mutex_lock (&overrides_lock);
+ scm_dynwind_begin (0);
+ /* Here we must block asyncs while overrides_lock is held, to avoid
+ deadlocks which can happen as follows: scm_i_program_properties
+ calls out to the VM, which will run asyncs. Asyncs are permitted
+ to run VM code, which sometimes checks procedure properties, which
+ locks overrides_lock. */
+ scm_i_dynwind_pthread_mutex_lock_block_asyncs (&overrides_lock);
props = scm_hashq_ref (overrides, proc, SCM_BOOL_F);
if (scm_is_false (props))
{
props = scm_hashq_ref (overrides, proc, SCM_BOOL_F);
if (scm_is_false (props))
{
props = SCM_EOL;
}
scm_hashq_set_x (overrides, proc, scm_assq_set_x (props, key, val));
props = SCM_EOL;
}
scm_hashq_set_x (overrides, proc, scm_assq_set_x (props, key, val));
- scm_i_pthread_mutex_unlock (&overrides_lock);
return SCM_UNSPECIFIED;
}
return SCM_UNSPECIFIED;
}