mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
Correct race condition and incorrect usage of condition_signal outside of a mutex lock
This commit is contained in:
@@ -704,6 +704,7 @@ void add_constant_switch_case(CheckerContext *ctx, Map<TypeAndToken> *seen, Oper
|
|||||||
if (operand.value.kind == ExactValue_Invalid) {
|
if (operand.value.kind == ExactValue_Invalid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashKey key = hash_exact_value(operand.value);
|
HashKey key = hash_exact_value(operand.value);
|
||||||
TypeAndToken *found = map_get(seen, key);
|
TypeAndToken *found = map_get(seen, key);
|
||||||
if (found != nullptr) {
|
if (found != nullptr) {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
// TODO(bill): Big numbers
|
// TODO(bill): Big numbers
|
||||||
// IMPORTANT TODO(bill): This needs to be completely fixed!!!!!!!!
|
// IMPORTANT TODO(bill): This needs to be completely fixed!!!!!!!!
|
||||||
|
|
||||||
|
gb_global BlockingMutex hash_exact_value_mutex;
|
||||||
|
|
||||||
struct Ast;
|
struct Ast;
|
||||||
struct HashKey;
|
struct HashKey;
|
||||||
struct Type;
|
struct Type;
|
||||||
@@ -62,6 +64,9 @@ struct ExactValue {
|
|||||||
gb_global ExactValue const empty_exact_value = {};
|
gb_global ExactValue const empty_exact_value = {};
|
||||||
|
|
||||||
HashKey hash_exact_value(ExactValue v) {
|
HashKey hash_exact_value(ExactValue v) {
|
||||||
|
mutex_lock(&hash_exact_value_mutex);
|
||||||
|
defer (mutex_unlock(&hash_exact_value_mutex));
|
||||||
|
|
||||||
HashKey empty = {};
|
HashKey empty = {};
|
||||||
switch (v.kind) {
|
switch (v.kind) {
|
||||||
case ExactValue_Invalid:
|
case ExactValue_Invalid:
|
||||||
|
|||||||
@@ -676,6 +676,8 @@ lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue return_ptr,
|
|||||||
for (unsigned i = 0; i < param_count; i++) {
|
for (unsigned i = 0; i < param_count; i++) {
|
||||||
LLVMTypeRef param_type = param_types[i];
|
LLVMTypeRef param_type = param_types[i];
|
||||||
LLVMTypeRef arg_type = LLVMTypeOf(args[i]);
|
LLVMTypeRef arg_type = LLVMTypeOf(args[i]);
|
||||||
|
// LLVMTypeKind param_kind = LLVMGetTypeKind(param_type);
|
||||||
|
// LLVMTypeKind arg_kind = LLVMGetTypeKind(arg_type);
|
||||||
GB_ASSERT_MSG(
|
GB_ASSERT_MSG(
|
||||||
arg_type == param_type,
|
arg_type == param_type,
|
||||||
"Parameter types do not match: %s != %s, argument: %s",
|
"Parameter types do not match: %s != %s, argument: %s",
|
||||||
|
|||||||
@@ -2018,6 +2018,7 @@ int main(int arg_count, char const **arg_ptr) {
|
|||||||
|
|
||||||
virtual_memory_init();
|
virtual_memory_init();
|
||||||
mutex_init(&fullpath_mutex);
|
mutex_init(&fullpath_mutex);
|
||||||
|
mutex_init(&hash_exact_value_mutex);
|
||||||
|
|
||||||
init_string_buffer_memory();
|
init_string_buffer_memory();
|
||||||
init_string_interner();
|
init_string_interner();
|
||||||
|
|||||||
+1
-1
@@ -93,8 +93,8 @@ bool thread_pool_add_task(ThreadPool *pool, WorkerTaskProc *proc, void *data) {
|
|||||||
thread_pool_queue_push(pool, task);
|
thread_pool_queue_push(pool, task);
|
||||||
GB_ASSERT(pool->ready >= 0);
|
GB_ASSERT(pool->ready >= 0);
|
||||||
pool->ready++;
|
pool->ready++;
|
||||||
mutex_unlock(&pool->mutex);
|
|
||||||
condition_signal(&pool->task_cond);
|
condition_signal(&pool->task_cond);
|
||||||
|
mutex_unlock(&pool->mutex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user