aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-08-16 15:33:26 +0100
committergingerBill <bill@gingerbill.org>2021-08-16 15:33:26 +0100
commit94d298755a6036c3dbbf95aed3299e021c3fb9c8 (patch)
treee286061f5150d083616e64886fcef267fc03866f /src/check_expr.cpp
parent5f072591ba70abf6df59f4ed9372649e7ebda710 (diff)
Fix race condition when adding a dependency
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 30f44a59f..e0eb5a954 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -4117,20 +4117,23 @@ bool check_identifier_exists(Scope *s, Ast *node, bool nested = false, Scope **o
}
isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lhs, isize lhs_count, isize tuple_index, isize tuple_count) {
- if (lhs != nullptr) {
+ if (lhs != nullptr && c->decl != nullptr) {
+ mutex_lock(&c->info->deps_mutex);
+
for (isize j = 0; (tuple_index + j) < lhs_count && j < tuple_count; j++) {
Entity *e = lhs[tuple_index + j];
if (e != nullptr) {
DeclInfo *decl = decl_info_of_entity(e);
if (decl != nullptr) {
- c->decl = decl; // will be reset by the 'defer' any way
for_array(k, decl->deps.entries) {
Entity *dep = decl->deps.entries[k].ptr;
- add_declaration_dependency(c, dep); // TODO(bill): Should this be here?
+ ptr_set_add(&c->decl->deps, dep);
}
}
}
}
+
+ mutex_unlock(&c->info->deps_mutex);
}
return tuple_count;
}