Skip to content

Commit

Permalink
Workaround to avoid stack overflow in .NET with larger workloads
Browse files Browse the repository at this point in the history
Before applying this workaround, the Elm compiler caused a stack overflow depending on the source module.
  • Loading branch information
Viir committed May 20, 2024
1 parent 8232d0c commit 640a845
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions implement/pine/Pine/PineVM/PineVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,20 @@ Result<string, PineValue> continueWithEnvValueAndFunction(
FunctionApplicationMaxEnvSize < list.Elements.Count ? list.Elements.Count : FunctionApplicationMaxEnvSize;
}

/*
* 2024-05-19 work around for stack overflow:
* After seeing some apps crash with stack overflow, reduce stack sizes by offloading to another thread.
*
var evalResult = EvaluateExpression(environment: environmentValue, expression: functionExpression);
return evalResult;
*/

var task =
System.Threading.Tasks.Task.Run(() => EvaluateExpression(environment: environmentValue, expression: functionExpression));

return task.Result;
};

return
Expand Down

0 comments on commit 640a845

Please sign in to comment.