Skip to content

Commit d22b61e

Browse files
committed
fix: increase .NET default stack size on macOS CI to prevent stack overflow
1 parent 3672866 commit d22b61e

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

src/AElf.Runtime.CSharp/Executive.cs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,6 @@ namespace AElf.Runtime.CSharp;
2121

2222
public class Executive : IExecutive
2323
{
24-
/// <summary>
25-
/// Safely converts an exception to string without accessing StackTrace.
26-
/// IMPORTANT: Do NOT call ex.ToString() as it accesses StackTrace property,
27-
/// which can trigger StackOverflowException when the stack is nearly exhausted.
28-
/// StackOverflowException cannot be caught by try-catch in .NET.
29-
/// </summary>
30-
private static string SafeExceptionToString(Exception ex)
31-
{
32-
// Keep this method as simple as possible to minimize stack usage
33-
// when the stack is nearly exhausted
34-
try
35-
{
36-
// Only use GetType() and Message - these don't access StackTrace
37-
return string.Concat(ex.GetType().FullName, ": ", ex.Message);
38-
}
39-
catch
40-
{
41-
return "Exception occurred";
42-
}
43-
}
44-
4524
private readonly ReadOnlyDictionary<string, IServerCallHandler> _callHandlers;
4625
private readonly object _contractInstance;
4726
private readonly ServerServiceDefinition _serverServiceDefinition;
@@ -169,7 +148,7 @@ public void Execute()
169148
catch (Exception ex)
170149
{
171150
CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.SystemError;
172-
CurrentTransactionContext.Trace.Error += SafeExceptionToString(ex) + "\n";
151+
CurrentTransactionContext.Trace.Error += ex + "\n";
173152
}
174153
finally
175154
{
@@ -206,7 +185,7 @@ private void ExecuteTransaction(IServerCallHandler handler)
206185
catch (Exception ex)
207186
{
208187
CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError;
209-
CurrentTransactionContext.Trace.Error += SafeExceptionToString(ex) + "\n";
188+
CurrentTransactionContext.Trace.Error += ex + "\n";
210189
}
211190
}
212191

templates/build-template-macos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
vmImage: macos-latest
1818
variables:
1919
CI_TEST: true
20+
# set the default stack size to 1.5MB
21+
DOTNET_DefaultStackSize: 1572864
2022
steps:
2123
- task: UseDotNet@2
2224
displayName: 'Install .NET Core SDK'

0 commit comments

Comments
 (0)