Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac crash dumps #71706

Merged
merged 9 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28975,7 +28975,7 @@ public void M()
comp.VerifyEmitDiagnostics();
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/70381")]
[ConditionalFact(typeof(WindowsOrLinuxOnly)), WorkItem("https://github.com/dotnet/roslyn/issues/70381")]
public void ExtremelyNestedCollectionExpressionDoesNotOverflow_1()
{
var code = $$"""
Expand Down
18 changes: 10 additions & 8 deletions src/Compilers/CSharp/Test/EndToEnd/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Threading;
using System.Diagnostics;
using Roslyn.Test.Utilities.TestGenerators;
using System.Runtime.InteropServices;

namespace Microsoft.CodeAnalysis.CSharp.UnitTests.EndToEnd
{
Expand Down Expand Up @@ -174,14 +175,15 @@ void M2() {
[Fact, WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1874763")]
public void OverflowOnFluentCall_ExtensionMethods()
{
int numberFluentCalls = (IntPtr.Size, ExecutionConditionUtil.Configuration, RuntimeUtilities.IsDesktopRuntime) switch
{
(8, ExecutionConfiguration.Debug, false) => 750,
(8, ExecutionConfiguration.Release, false) => 750, // Should be ~3_400, but is flaky.
(4, ExecutionConfiguration.Debug, true) => 450,
(4, ExecutionConfiguration.Release, true) => 1_600,
(8, ExecutionConfiguration.Debug, true) => 1_100,
(8, ExecutionConfiguration.Release, true) => 3_300,
int numberFluentCalls = (IntPtr.Size, ExecutionConditionUtil.Configuration, RuntimeUtilities.IsDesktopRuntime, RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) switch
{
(8, ExecutionConfiguration.Debug, false, false) => 750,
(8, ExecutionConfiguration.Release, false, false) => 750, // Should be ~3_400, but is flaky.
(4, ExecutionConfiguration.Debug, true, false) => 450,
(4, ExecutionConfiguration.Release, true, false) => 1_600,
(8, ExecutionConfiguration.Debug, true, false) => 1_100,
(8, ExecutionConfiguration.Release, true, false) => 3_300,
(_, _, _, true) => 200,
_ => throw new Exception($"Unexpected configuration {IntPtr.Size * 8}-bit {ExecutionConditionUtil.Configuration}, Desktop: {RuntimeUtilities.IsDesktopRuntime}")
};

Expand Down
35 changes: 32 additions & 3 deletions src/Tools/Source/RunTests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ string MakeHelixWorkItemProject(WorkItemInfo workItemInfo)
// We could relax this and allow for example Linux clients to kick off Windows jobs, but we'd have to
// figure out solutions for issues such as creating file paths in the correct format for the target machine.
var isUnix = !RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
var isMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

var setEnvironmentVariable = isUnix ? "export" : "set";

Expand All @@ -202,15 +203,40 @@ string MakeHelixWorkItemProject(WorkItemInfo workItemInfo)
command.AppendLine(isUnix ? $"ls -l" : $"dir");
command.AppendLine("dotnet --info");

var knownEnvironmentVariables = new[] { "ROSLYN_TEST_IOPERATION", "ROSLYN_TEST_USEDASSEMBLIES" };
string[] knownEnvironmentVariables =
[
"ROSLYN_TEST_IOPERATION",
"ROSLYN_TEST_USEDASSEMBLIES"
];

foreach (var knownEnvironmentVariable in knownEnvironmentVariables)
{
if (string.Equals(Environment.GetEnvironmentVariable(knownEnvironmentVariable), "true", StringComparison.OrdinalIgnoreCase))
if (Environment.GetEnvironmentVariable(knownEnvironmentVariable) is string { Length: > 0 } value)
{
command.AppendLine($"{setEnvironmentVariable} {knownEnvironmentVariable}=true");
command.AppendLine($"{setEnvironmentVariable} {knownEnvironmentVariable}=\"{value}\"");
}
}

// OSX produces extremely large dump files that commonly exceed the limits of Helix
// uploads. These settings limit the dump file size + produce a .json detailing crash
// reasons that work better with Helix size limitations.
if (isMac)
{
command.AppendLine($"{setEnvironmentVariable} DOTNET_DbgEnableMiniDump=1");
command.AppendLine($"{setEnvironmentVariable} DOTNET_DbgMiniDumpType=1");
command.AppendLine($"{setEnvironmentVariable} DOTNET_EnableCrashReport=1");
}

// Set the dump folder so that dotnet writes all dump files to this location automatically.
// This saves the need to scan for all the different types of dump files later and copy
// them around.
var helixDumpFolder = isUnix
? @"$HELIX_DUMP_FOLDER/crash.%d.%e.dmp"
: @"%HELIX_DUMP_FOLDER%\crash.%d.%e.dmp";
command.AppendLine($"{setEnvironmentVariable} DOTNET_DbgMiniDumpName=\"{helixDumpFolder}\"");

command.AppendLine(isUnix ? "env | sort" : "set");

// Create a payload directory that contains all the assemblies in the work item in separate folders.
var payloadDirectory = Path.Combine(msbuildTestPayloadRoot, "artifacts", "bin");

Expand Down Expand Up @@ -259,6 +285,9 @@ string MakeHelixWorkItemProject(WorkItemInfo workItemInfo)
// return value of the main command is captured; a Helix Job is considered to fail if the main command returns a
// non-zero error code, and we don't want the cleanup steps to interefere with that. PostCommands exist
// precisely to address this problem.
//
// This is still necessary even with us setting DOTNET_DbgMiniDumpName because the system can create
// non .NET Core dump files that aren't controlled by that value.
var postCommands = new StringBuilder();

if (isUnix)
Expand Down
Loading