mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Fix race condition in error_va
If the error count exceeded `MAX_ERROR_COLLECTOR_COUNT`, multiple threads could print and exit simultaneously, causing a segfault. This change moves the mutex lock back before the conditional.
This commit is contained in:
+1
-1
@@ -376,11 +376,11 @@ gb_internal void error_out_coloured(char const *str, TerminalStyle style, Termin
|
|||||||
|
|
||||||
gb_internal void error_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) {
|
gb_internal void error_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) {
|
||||||
global_error_collector.count.fetch_add(1);
|
global_error_collector.count.fetch_add(1);
|
||||||
|
mutex_lock(&global_error_collector.mutex);
|
||||||
if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) {
|
if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) {
|
||||||
print_all_errors();
|
print_all_errors();
|
||||||
gb_exit(1);
|
gb_exit(1);
|
||||||
}
|
}
|
||||||
mutex_lock(&global_error_collector.mutex);
|
|
||||||
|
|
||||||
push_error_value(pos, ErrorValue_Error);
|
push_error_value(pos, ErrorValue_Error);
|
||||||
// NOTE(bill): Duplicate error, skip it
|
// NOTE(bill): Duplicate error, skip it
|
||||||
|
|||||||
Reference in New Issue
Block a user