Skip to content

Commit

Permalink
Place VM reset in Runtime Core mutex context (#10577)
Browse files Browse the repository at this point in the history
Enlarged the mutually exclusive context in ResetVMAndResyncGraph to
also include ReInitializeLiveRunner. This is important as the
reinitialization of the runner resets the runtime core, making the
Design Script executable null, which will cause any running executions
to crash Dynamo, even respecting the mutually exclusive context.
  • Loading branch information
mmisol authored Apr 20, 2020
1 parent 8a40cc0 commit a3209dc
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/Engine/ProtoScript/Runners/LiveRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,7 @@ public void UpdateGraph(AssociativeNode astNode)
/// This api needs to be called by a command line REPL for each DS command/expression entered to be executed
/// </summary>
/// <param name="code"></param>
[Obsolete("No longer used. Remove in 3.0")]
public void UpdateCmdLineInterpreter(string code)
{
lock (mutexObject)
Expand Down Expand Up @@ -1532,27 +1533,30 @@ public void ReInitializeLiveRunner()
/// <param name="syncData"></param>
public void ResetVMAndResyncGraph(IEnumerable<string> libraries)
{
// Reset VM
ReInitializeLiveRunner();

if (!libraries.Any())
lock (mutexObject)
{
return;
}
// Reset VM. This needs to be in mutex context as it turns DSExecutable null.
ReInitializeLiveRunner();

// generate import node for each library in input list
List<AssociativeNode> importNodes = new List<AssociativeNode>();
foreach (string lib in libraries)
{
ProtoCore.AST.AssociativeAST.ImportNode importNode = new ProtoCore.AST.AssociativeAST.ImportNode();
importNode.ModuleName = lib;
if (!libraries.Any())
{
return;
}

importNodes.Add(importNode);
}
ProtoCore.CodeGenDS codeGen = new ProtoCore.CodeGenDS(importNodes);
string code = codeGen.GenerateCode();
// generate import node for each library in input list
List<AssociativeNode> importNodes = new List<AssociativeNode>();
foreach (string lib in libraries)
{
ProtoCore.AST.AssociativeAST.ImportNode importNode = new ProtoCore.AST.AssociativeAST.ImportNode();
importNode.ModuleName = lib;

UpdateCmdLineInterpreter(code);
importNodes.Add(importNode);
}
ProtoCore.CodeGenDS codeGen = new ProtoCore.CodeGenDS(importNodes);
string code = codeGen.GenerateCode();

SynchronizeInternal(code);
}
}

/// <summary>
Expand Down

0 comments on commit a3209dc

Please sign in to comment.