mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 15:44:04 +00:00
Use RecursiveMutex to fix a race condition with parapoly records
This commit is contained in:
@@ -1293,6 +1293,11 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
|
||||
error_line("\t Got: %s\n", s_got);
|
||||
gb_string_free(s_got);
|
||||
gb_string_free(s_expected);
|
||||
|
||||
Type *tx = x->Proc.params->Tuple.variables[0]->type;
|
||||
Type *ty = y->Proc.params->Tuple.variables[0]->type;
|
||||
gb_printf_err("%s kind:%.*s e:%p ot:%p\n", type_to_string(tx), LIT(type_strings[tx->kind]), tx->Named.type_name, tx->Named.type_name->TypeName.original_type_for_parapoly);
|
||||
gb_printf_err("%s kind:%.*s e:%p ot:%p\n", type_to_string(ty), LIT(type_strings[ty->kind]), ty->Named.type_name, ty->Named.type_name->TypeName.original_type_for_parapoly);
|
||||
} else {
|
||||
gbString s_expected = type_to_string(y);
|
||||
gbString s_got = type_to_string(x);
|
||||
@@ -7908,11 +7913,10 @@ gb_internal CallArgumentError check_polymorphic_record_type(CheckerContext *c, O
|
||||
|
||||
{
|
||||
GenTypesData *found_gen_types = ensure_polymorphic_record_entity_has_gen_types(c, original_type);
|
||||
mutex_lock(&found_gen_types->mutex);
|
||||
defer (mutex_unlock(&found_gen_types->mutex));
|
||||
|
||||
rw_mutex_shared_lock(&found_gen_types->mutex);
|
||||
Entity *found_entity = find_polymorphic_record_entity(found_gen_types, param_count, ordered_operands);
|
||||
rw_mutex_shared_unlock(&found_gen_types->mutex);
|
||||
|
||||
if (found_entity) {
|
||||
operand->mode = Addressing_Type;
|
||||
operand->type = found_entity->type;
|
||||
|
||||
@@ -312,6 +312,7 @@ gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, T
|
||||
e->state = EntityState_Resolved;
|
||||
e->file = ctx->file;
|
||||
e->pkg = pkg;
|
||||
e->TypeName.original_type_for_parapoly = original_type;
|
||||
add_entity_use(ctx, node, e);
|
||||
}
|
||||
|
||||
@@ -321,8 +322,8 @@ gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, T
|
||||
e->TypeName.objc_metadata = original_type->Named.type_name->TypeName.objc_metadata;
|
||||
|
||||
auto *found_gen_types = ensure_polymorphic_record_entity_has_gen_types(ctx, original_type);
|
||||
rw_mutex_lock(&found_gen_types->mutex);
|
||||
defer (rw_mutex_unlock(&found_gen_types->mutex));
|
||||
mutex_lock(&found_gen_types->mutex);
|
||||
defer (mutex_unlock(&found_gen_types->mutex));
|
||||
|
||||
for (Entity *prev : found_gen_types->types) {
|
||||
if (prev == e) {
|
||||
|
||||
@@ -417,7 +417,7 @@ struct GenProcsData {
|
||||
|
||||
struct GenTypesData {
|
||||
Array<Entity *> types;
|
||||
RwMutex mutex;
|
||||
RecursiveMutex mutex;
|
||||
};
|
||||
|
||||
struct Defineable {
|
||||
|
||||
@@ -234,6 +234,7 @@ struct Entity {
|
||||
} Variable;
|
||||
struct {
|
||||
Type * type_parameter_specialization;
|
||||
Type * original_type_for_parapoly;
|
||||
String ir_mangled_name;
|
||||
bool is_type_alias;
|
||||
bool objc_is_implementation;
|
||||
|
||||
@@ -18,8 +18,8 @@ enum BasicKind {
|
||||
Basic_u16,
|
||||
Basic_i32,
|
||||
Basic_u32,
|
||||
Basic_i64,
|
||||
Basic_u64,
|
||||
Basic_i64
|
||||
, Basic_u64,
|
||||
Basic_i128,
|
||||
Basic_u128,
|
||||
|
||||
@@ -2860,6 +2860,7 @@ gb_internal bool are_types_identical(Type *x, Type *y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// MUTEX_GUARD(&g_type_mutex);
|
||||
return are_types_identical_internal(x, y, false);
|
||||
}
|
||||
gb_internal bool are_types_identical_unique_tuples(Type *x, Type *y) {
|
||||
@@ -2887,6 +2888,7 @@ gb_internal bool are_types_identical_unique_tuples(Type *x, Type *y) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// MUTEX_GUARD(&g_type_mutex);
|
||||
return are_types_identical_internal(x, y, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user