From 041ebdd8f6b9cc3c2274ae9284e51d0e70602e00 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 2 Feb 2026 11:39:17 +0000 Subject: [PATCH 1/4] Add parent mutex lock for `scope_insert_with_name` --- src/checker.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/checker.cpp b/src/checker.cpp index 9568b8cfa..71ccfebc4 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -495,15 +495,18 @@ gb_internal Entity *scope_insert_with_name(Scope *s, String const &name, Entity goto end; } if (s->parent != nullptr && (s->parent->flags & ScopeFlag_Proc) != 0) { + rw_mutex_shared_lock(&s->parent->mutex); found = string_map_get(&s->parent->elements, key); if (found) { if ((*found)->flags & EntityFlag_Result) { if (entity != *found) { result = *found; } + rw_mutex_shared_unlock(&s->parent->mutex); goto end; } } + rw_mutex_shared_unlock(&s->parent->mutex); } string_map_set(&s->elements, key, entity); From 2bbedda61c91eca763b4ef07e889c12372c66560 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 2 Feb 2026 11:39:57 +0000 Subject: [PATCH 2/4] Remove unneeded mutex in `hash_exact_value` --- src/exact_value.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/exact_value.cpp b/src/exact_value.cpp index 0f425e043..fa99ed3fe 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -1,8 +1,6 @@ #include #include -gb_global BlockingMutex hash_exact_value_mutex; - struct Ast; struct HashKey; struct Type; @@ -54,9 +52,6 @@ struct ExactValue { gb_global ExactValue const empty_exact_value = {}; gb_internal uintptr hash_exact_value(ExactValue v) { - mutex_lock(&hash_exact_value_mutex); - defer (mutex_unlock(&hash_exact_value_mutex)); - uintptr res = 0; switch (v.kind) { From 8594deb4e1f0c75fdcf5e0351e193f2d9e267b5f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 2 Feb 2026 11:40:30 +0000 Subject: [PATCH 3/4] Move `return true;` to after the if check --- src/types.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types.cpp b/src/types.cpp index 9ecdf5cdd..fa4aa8730 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -4317,8 +4317,8 @@ gb_internal bool type_set_offsets(Type *t) { t->Struct.offsets = type_set_offsets_of(t->Struct.fields, t->Struct.is_packed, t->Struct.is_raw_union, t->Struct.custom_min_field_align, t->Struct.custom_max_field_align); t->Struct.are_offsets_being_processed.store(false); t->Struct.are_offsets_set = true; - return true; } + return true; } else if (is_type_tuple(t)) { MUTEX_GUARD(&t->Tuple.mutex); if (!t->Tuple.are_offsets_set) { @@ -4326,8 +4326,8 @@ gb_internal bool type_set_offsets(Type *t) { t->Tuple.offsets = type_set_offsets_of(t->Tuple.variables, t->Tuple.is_packed, false, 1, 0); t->Tuple.are_offsets_being_processed.store(false); t->Tuple.are_offsets_set = true; - return true; } + return true; } else { GB_PANIC("Invalid type for setting offsets"); } From a936f3fb7d3f6e6abf5e2599b7043625a1a0c17b Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 2 Feb 2026 11:41:33 +0000 Subject: [PATCH 4/4] Comment out `t->Struct.are_offsets_being_processed.load()` --- src/types.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types.cpp b/src/types.cpp index fa4aa8730..0ecce1adc 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -4308,9 +4308,9 @@ gb_internal i64 *type_set_offsets_of(Slice const &fields, bool is_pack gb_internal bool type_set_offsets(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { - if (t->Struct.are_offsets_being_processed.load()) { - return true; - } + // if (t->Struct.are_offsets_being_processed.load()) { + // return true; + // } MUTEX_GUARD(&t->Struct.offset_mutex); if (!t->Struct.are_offsets_set) { t->Struct.are_offsets_being_processed.store(true);