Shrink lock region of func_raw_types_mutex to avoid deadlock.

This commit is contained in:
Franz
2026-07-15 23:14:24 +02:00
parent 7c2b219259
commit cd577b2eef

View File

@@ -1781,13 +1781,15 @@ gb_internal LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *t
GB_ASSERT(type->kind == Type_Proc);
mutex_lock(&m->func_raw_types_mutex);
defer (mutex_unlock(&m->func_raw_types_mutex));
LLVMTypeRef *found = map_get(&m->func_raw_types, type);
if (found) {
mutex_unlock(&m->func_raw_types_mutex);
return *found;
}
mutex_unlock(&m->func_raw_types_mutex);
unsigned param_count = 0;
if (type->Proc.param_count != 0) {
@@ -1896,7 +1898,9 @@ gb_internal LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *t
"\n\tFuncTypeCtx: %p\n\tCurrentCtx: %p\n\tGlobalCtx: %p",
LLVMGetTypeContext(new_abi_fn_type), m->ctx);
mutex_lock(&m->func_raw_types_mutex);
map_set(&m->func_raw_types, type, new_abi_fn_type);
mutex_unlock(&m->func_raw_types_mutex);
return new_abi_fn_type;
}