From 8babc47638bdcc0b4a8688cdf2246d7ad29a8ff5 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 6 Mar 2023 03:59:35 +0100 Subject: [PATCH] compiler: fix a race condition There was a mostly benign race condition in the compiler. The issue was that there is a check for type aliases (which can alias types in another function), but this check was _after_ accessing a property of the function that might not have been completed. I don't think this can have any serious effects, as the function is skipped anyway, but such bugs should certainly be fixed. --- compiler/compiler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/compiler.go b/compiler/compiler.go index 15cdab9f..de3f69a1 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -869,14 +869,14 @@ func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package if fn == nil { continue // probably a generic method } - if fn.Blocks == nil { - continue // external function - } if member.Type().String() != member.String() { // This is a member on a type alias. Do not build such a // function. continue } + if fn.Blocks == nil { + continue // external function + } if fn.Synthetic != "" && fn.Synthetic != "package initializer" { // This function is a kind of wrapper function (created by // the ssa package, not appearing in the source code) that