You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/04/27 19:20:00 UTC
[ignite] branch master updated: IGNITE-14644 .NET: Log a warning
about COMPlus_EnableAlternateStackCheck
This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new f97b932 IGNITE-14644 .NET: Log a warning about COMPlus_EnableAlternateStackCheck
f97b932 is described below
commit f97b932849eff35b7849b30c84468aeede14d378
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Tue Apr 27 22:19:30 2021 +0300
IGNITE-14644 .NET: Log a warning about COMPlus_EnableAlternateStackCheck
On Linux, Java overwrites SIGSEGV handler installed by .NET, so NullReferenceException causes a confusing "Stack smashing detected" error. This can be fixed by setting COMPlus_EnableAlternateStackCheck environment variable. Log a warning to raise user awareness.
---
.../dotnet/Apache.Ignite.Core/Ignition.cs | 40 +++++++++++++++++-----
1 file changed, 31 insertions(+), 9 deletions(-)
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index fcd57f3..510d639 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -66,11 +66,18 @@ namespace Apache.Ignite.Core
/// </summary>
public const string ClientConfigurationSectionName = "igniteClientConfiguration";
+ /// <summary>
+ /// Environment variable name to enable alternate stack checks on .NET Core 3+ and .NET 5+.
+ /// This is required to fix "Stack smashing detected" errors that occur instead of NullReferenceException
+ /// on Linux and macOS when Java overwrites SIGSEGV handler installed by .NET in thick client or server mode.
+ /// </summary>
+ private const string EnvEnableAlternateStackCheck = "COMPlus_EnableAlternateStackCheck";
+
/** */
private static readonly object SyncRoot = new object();
/** GC warning flag. */
- private static int _gcWarn;
+ private static int _diagPrinted;
/** */
private static readonly IDictionary<NodeKey, Ignite> Nodes = new Dictionary<NodeKey, Ignite>();
@@ -243,8 +250,8 @@ namespace Apache.Ignite.Core
log.Debug("Starting Ignite.NET " + Assembly.GetExecutingAssembly().GetName().Version);
- // 1. Check GC settings.
- CheckServerGc(cfg, log);
+ // 1. Log diagnostics.
+ LogDiagnosticMessages(cfg, log);
// 2. Create context.
JvmDll.Load(cfg.JvmDllPath, log);
@@ -337,16 +344,31 @@ namespace Apache.Ignite.Core
}
/// <summary>
- /// Check whether GC is set to server mode.
+ /// Performs system checks and logs diagnostic messages.
/// </summary>
/// <param name="cfg">Configuration.</param>
/// <param name="log">Log.</param>
- private static void CheckServerGc(IgniteConfiguration cfg, ILogger log)
+ private static void LogDiagnosticMessages(IgniteConfiguration cfg, ILogger log)
{
- if (!cfg.SuppressWarnings && !GCSettings.IsServerGC && Interlocked.CompareExchange(ref _gcWarn, 1, 0) == 0)
- log.Warn("GC server mode is not enabled, this could lead to less " +
- "than optimal performance on multi-core machines (to enable see " +
- "http://msdn.microsoft.com/en-us/library/ms229357(v=vs.110).aspx).");
+ if (!cfg.SuppressWarnings &&
+ Interlocked.CompareExchange(ref _diagPrinted, 1, 0) == 0)
+ {
+ if (!GCSettings.IsServerGC)
+ {
+ log.Warn("GC server mode is not enabled, this could lead to less " +
+ "than optimal performance on multi-core machines (to enable see " +
+ "https://docs.microsoft.com/en-us/dotnet/core/run-time-config/garbage-collector).");
+ }
+
+ if ((Os.IsLinux || Os.IsMacOs) &&
+ Environment.GetEnvironmentVariable(EnvEnableAlternateStackCheck) != "1")
+ {
+ log.Warn("Alternate stack check is not enabled, this will cause 'Stack smashing detected' " +
+ "error when NullReferenceException occurs on .NET Core on Linux and macOS. " +
+ "To enable alternate stack check on .NET Core 3+ and .NET 5+, " +
+ "set {0} environment variable to 1.", EnvEnableAlternateStackCheck);
+ }
+ }
}
/// <summary>