From 8bd5f7d0af5743330f85601fab759eb08d3ad797 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 22 Jan 2019 16:53:22 +0100 Subject: [PATCH] Lock evaluation scope when not created to prevent threading issues --- Upsilon/StandardLibraries/StaticScope.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Upsilon/StandardLibraries/StaticScope.cs b/Upsilon/StandardLibraries/StaticScope.cs index d38f7c2..1e7706e 100644 --- a/Upsilon/StandardLibraries/StaticScope.cs +++ b/Upsilon/StandardLibraries/StaticScope.cs @@ -27,11 +27,13 @@ namespace Upsilon.StandardLibraries { if (_staticScope != null) return _staticScope; - - var (evaluationScope, boundScope) = CreateStandardLibrary(); - _staticScope = evaluationScope; - _staticBoundScope = boundScope; - return _staticScope; + lock (Scope) + { + var (evaluationScope, boundScope) = CreateStandardLibrary(); + _staticScope = evaluationScope; + _staticBoundScope = boundScope; + return _staticScope; + } } }