From eee72d1aae664bf6627ef955215d886dc7b105c0 Mon Sep 17 00:00:00 2001 From: Denys Smirnov Date: Tue, 13 Dec 2022 12:46:05 +0200 Subject: [PATCH] Fix deadlock after parsing directory with no files Currently if interpreter tries to eval an empty directory with no Go files it will error (as it should), but all future calls to eval will deadlock, because the mutex is not unlocked correctly. I believe this is a critical issue that must be addressed. --- interp/src.go | 1 + 1 file changed, 1 insertion(+) diff --git a/interp/src.go b/interp/src.go index f7ccfad87..86f75f717 100644 --- a/interp/src.go +++ b/interp/src.go @@ -133,6 +133,7 @@ func (interp *Interpreter) importSrc(rPath, importPath string, skipTest bool) (s interp.mutex.Lock() gs := interp.scopes[importPath] if gs == nil { + interp.mutex.Unlock() // A nil scope means that no even an empty package is created from source. return "", fmt.Errorf("no Go files in %s", dir) }