Browse Source

Disable `DEFAULT_TO_THREADED_CHECKER` until race condition is found

gingerBill 3 years ago
parent
commit
847b05013f
5 changed files with 24 additions and 25 deletions
  1. 13 13
      src/bug_report.cpp
  2. 1 1
      src/build_settings.cpp
  3. 4 5
      src/check_decl.cpp
  4. 5 5
      src/checker.cpp
  5. 1 1
      src/checker.hpp

+ 13 - 13
src/bug_report.cpp

@@ -140,7 +140,7 @@ void report_windows_product_type(DWORD ProductType) {
 		break;
 
 	default:
-		gb_printf("Unknown Edition (%08x)", ProductType);
+		gb_printf("Unknown Edition (%08x)", cast(unsigned)ProductType);
 	}
 }
 #endif
@@ -316,14 +316,14 @@ void print_bug_report_help() {
 			}
 
 			if (false) {
-				gb_printf("dwMajorVersion:    %d\n", osvi.dwMajorVersion);
-				gb_printf("dwMinorVersion:    %d\n", osvi.dwMinorVersion);
-				gb_printf("dwBuildNumber:     %d\n", osvi.dwBuildNumber);
-				gb_printf("dwPlatformId:      %d\n", osvi.dwPlatformId);
-				gb_printf("wServicePackMajor: %d\n", osvi.wServicePackMajor);
-				gb_printf("wServicePackMinor: %d\n", osvi.wServicePackMinor);
-				gb_printf("wSuiteMask:        %d\n", osvi.wSuiteMask);
-				gb_printf("wProductType:      %d\n", osvi.wProductType);
+				gb_printf("dwMajorVersion:    %u\n", cast(unsigned)osvi.dwMajorVersion);
+				gb_printf("dwMinorVersion:    %u\n", cast(unsigned)osvi.dwMinorVersion);
+				gb_printf("dwBuildNumber:     %u\n", cast(unsigned)osvi.dwBuildNumber);
+				gb_printf("dwPlatformId:      %u\n", cast(unsigned)osvi.dwPlatformId);
+				gb_printf("wServicePackMajor: %u\n", cast(unsigned)osvi.wServicePackMajor);
+				gb_printf("wServicePackMinor: %u\n", cast(unsigned)osvi.wServicePackMinor);
+				gb_printf("wSuiteMask:        %u\n", cast(unsigned)osvi.wSuiteMask);
+				gb_printf("wProductType:      %u\n", cast(unsigned)osvi.wProductType);
 			}
 
 			gb_printf("Windows ");
@@ -441,18 +441,18 @@ void print_bug_report_help() {
 				TEXT("DisplayVersion"),
 				RRF_RT_REG_SZ,
 				ValueType,
-				&DisplayVersion,
+				DisplayVersion,
 				&ValueSize
 			);
 
 			if (status == 0x0) {
-				gb_printf(" (version: %s)", &DisplayVersion);
+				gb_printf(" (version: %s)", DisplayVersion);
 			}
 
 			/*
 				Now print build number.
 			*/
-			gb_printf(", build %d", osvi.dwBuildNumber);
+			gb_printf(", build %u", cast(unsigned)osvi.dwBuildNumber);
 
 			ValueSize = sizeof(UBR);
 			status = RegGetValue(
@@ -466,7 +466,7 @@ void print_bug_report_help() {
 			);
 
 			if (status == 0x0) {
-				gb_printf(".%d", UBR);
+				gb_printf(".%u", cast(unsigned)UBR);
 			}
 			gb_printf("\n");
 		}

+ 1 - 1
src/build_settings.cpp

@@ -5,7 +5,7 @@
 
 
 // #if defined(GB_SYSTEM_WINDOWS)
-#define DEFAULT_TO_THREADED_CHECKER
+// #define DEFAULT_TO_THREADED_CHECKER
 // #endif
 
 enum TargetOsKind {

+ 4 - 5
src/check_decl.cpp

@@ -1286,7 +1286,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
 	using_entities.allocator = heap_allocator();
 	defer (array_free(&using_entities));
 
-	MUTEX_GUARD_BLOCK(ctx->scope->mutex) {
+	{
 		if (type->Proc.param_count > 0) {
 			TypeTuple *params = &type->Proc.params->Tuple;
 			for_array(i, params->variables) {
@@ -1303,7 +1303,7 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
 				if (t->kind == Type_Struct) {
 					Scope *scope = t->Struct.scope;
 					GB_ASSERT(scope != nullptr);
-					for_array(i, scope->elements.entries) {
+					MUTEX_GUARD_BLOCK(scope->mutex) for_array(i, scope->elements.entries) {
 						Entity *f = scope->elements.entries[i].value;
 						if (f->kind == Entity_Variable) {
 							Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr);
@@ -1321,11 +1321,10 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
 		}
 	}
 
-
-	for_array(i, using_entities) {
+	MUTEX_GUARD_BLOCK(ctx->scope->mutex) for_array(i, using_entities) {
 		Entity *e = using_entities[i].e;
 		Entity *uvar = using_entities[i].uvar;
-		Entity *prev = scope_insert(ctx->scope, uvar);
+		Entity *prev = scope_insert(ctx->scope, uvar, false);
 		if (prev != nullptr) {
 			error(e->token, "Namespace collision while 'using' procedure argument '%.*s' of: %.*s", LIT(e->token.string), LIT(prev->token.string));
 			error_line("%.*s != %.*s\n", LIT(uvar->token.string), LIT(prev->token.string));

+ 5 - 5
src/checker.cpp

@@ -446,7 +446,7 @@ Entity *scope_lookup(Scope *s, String const &name) {
 
 
 
-Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity) {
+Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity, bool use_mutex=true) {
 	if (name == "") {
 		return nullptr;
 	}
@@ -454,8 +454,8 @@ Entity *scope_insert_with_name(Scope *s, String const &name, Entity *entity) {
 	Entity **found = nullptr;
 	Entity *result = nullptr;
 
-	mutex_lock(&s->mutex);
-	defer (mutex_unlock(&s->mutex));
+	if (use_mutex) mutex_lock(&s->mutex);
+	defer (if (use_mutex) mutex_unlock(&s->mutex));
 	
 	found = string_map_get(&s->elements, key);
 
@@ -485,9 +485,9 @@ end:;
 	return result;
 }
 
-Entity *scope_insert(Scope *s, Entity *entity) {
+Entity *scope_insert(Scope *s, Entity *entity, bool use_mutex) {
 	String name = entity->token.string;
-	return scope_insert_with_name(s, name, entity);
+	return scope_insert_with_name(s, name, entity, use_mutex);
 }
 
 

+ 1 - 1
src/checker.hpp

@@ -423,7 +423,7 @@ Entity *entity_of_node(Ast *expr);
 Entity *scope_lookup_current(Scope *s, String const &name);
 Entity *scope_lookup (Scope *s, String const &name);
 void    scope_lookup_parent (Scope *s, String const &name, Scope **scope_, Entity **entity_);
-Entity *scope_insert (Scope *s, Entity *entity);
+Entity *scope_insert (Scope *s, Entity *entity, bool use_mutex=true);
 
 
 void      add_type_and_value      (CheckerInfo *i, Ast *expression, AddressingMode mode, Type *type, ExactValue value);