From 843eaf8893e3a7df9645c0bcba86c71a01a14765 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 18 Apr 2023 17:20:50 +0100 Subject: Fix race condition with -use-separate-modules due to type determination --- src/llvm_backend_general.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/llvm_backend_general.cpp') diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index aa887418f..7d2f574fe 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -1498,6 +1498,9 @@ gb_internal LLVMTypeRef lb_type_internal_for_procedures_raw(lbModule *m, Type *t type = base_type(original_type); 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) { return *found; @@ -2157,6 +2160,9 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) { gb_internal LLVMTypeRef lb_type(lbModule *m, Type *type) { type = default_type(type); + mutex_lock(&m->types_mutex); + defer (mutex_unlock(&m->types_mutex)); + LLVMTypeRef *found = map_get(&m->types, type); if (found) { return *found; -- cgit v1.2.3