aboutsummaryrefslogtreecommitdiff
path: root/src/exact_value.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-08-26 22:17:51 +0100
committergingerBill <bill@gingerbill.org>2021-08-26 22:17:51 +0100
commitb33bf3f7042464ac4f6e187fc487ee42668fcef7 (patch)
treea60151734e843e3efd542267eff16fe071fdb432 /src/exact_value.cpp
parent726788a48310971b0df8f431968100786d2f8cab (diff)
Correct race condition and incorrect usage of `condition_signal` outside of a mutex lock
Diffstat (limited to 'src/exact_value.cpp')
-rw-r--r--src/exact_value.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/exact_value.cpp b/src/exact_value.cpp
index 17b593995..d42f5359e 100644
--- a/src/exact_value.cpp
+++ b/src/exact_value.cpp
@@ -3,6 +3,8 @@
// TODO(bill): Big numbers
// IMPORTANT TODO(bill): This needs to be completely fixed!!!!!!!!
+gb_global BlockingMutex hash_exact_value_mutex;
+
struct Ast;
struct HashKey;
struct Type;
@@ -62,6 +64,9 @@ struct ExactValue {
gb_global ExactValue const empty_exact_value = {};
HashKey hash_exact_value(ExactValue v) {
+ mutex_lock(&hash_exact_value_mutex);
+ defer (mutex_unlock(&hash_exact_value_mutex));
+
HashKey empty = {};
switch (v.kind) {
case ExactValue_Invalid: