Skip to content
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 @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Threading;
using System.Runtime.CompilerServices;

namespace TestStackOverflow
{
Expand Down Expand Up @@ -67,39 +68,47 @@ struct LargeStruct65536
}
class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
static void InfiniteRecursionA()
{
InfiniteRecursionB();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void InfiniteRecursionB()
{
InfiniteRecursionC();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void InfiniteRecursionC()
{
InfiniteRecursionA();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void InfiniteRecursionA2()
{
LargeStruct65536 s;
InfiniteRecursionB2();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void InfiniteRecursionB2()
{
LargeStruct65536 s;
InfiniteRecursionC2();
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void InfiniteRecursionC2()
{
LargeStruct65536 s;
InfiniteRecursionA2();
}

static void MainThreadTest(bool smallframe)
[MethodImpl(MethodImplOptions.NoInlining)]
static void Test(bool smallframe)
{
if (smallframe)
{
Expand All @@ -116,16 +125,7 @@ static void SecondaryThreadsTest(bool smallframe)
Thread[] threads = new Thread[32];
for (int i = 0; i < threads.Length; i++)
{
threads[i] = new Thread(() => {
if (smallframe)
{
InfiniteRecursionA();
}
else
{
InfiniteRecursionA2();
}
});
threads[i] = new Thread(() => Test(smallframe));
threads[i].Start();
}

Expand All @@ -144,7 +144,7 @@ static void Main(string[] args)
}
else if (args[1] == "main")
{
MainThreadTest(smallframe);
Test(smallframe);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ static bool TestStackOverflowSmallFrameMainThread()
return false;
}

if (!lines.Exists(elem => elem.EndsWith("TestStackOverflow.Program.Test(Boolean)")))
{
Console.WriteLine("Missing \"Test\" method frame");
return false;
}

if (!lines.Exists(elem => elem.EndsWith("at TestStackOverflow.Program.InfiniteRecursionA()")))
{
Console.WriteLine("Missing \"InfiniteRecursionA\" method frame");
Expand Down Expand Up @@ -112,9 +118,9 @@ static bool TestStackOverflowLargeFrameMainThread()
return false;
}

if (!lines.Exists(elem => elem.EndsWith("TestStackOverflow.Program.MainThreadTest(Boolean)")))
if (!lines.Exists(elem => elem.EndsWith("TestStackOverflow.Program.Test(Boolean)")))
{
Console.WriteLine("Missing \"MainThreadTest\" method frame");
Console.WriteLine("Missing \"Test\" method frame");
return false;
}

Expand Down Expand Up @@ -147,9 +153,9 @@ static bool TestStackOverflowSmallFrameSecondaryThread()
List<string> lines;
if (TestStackOverflow("stackoverflow", "smallframe secondary", out lines))
{
if (!lines[lines.Count - 1].EndsWith("at System.Threading.ThreadHelper.ThreadStart()"))
if (!lines.Exists(elem => elem.EndsWith("at TestStackOverflow.Program.Test(Boolean)")))
{
Console.WriteLine("Missing \"System.Threading.ThreadHelper.ThreadStart\" method frame at the last line");
Console.WriteLine("Missing \"TestStackOverflow.Program.Test\" method frame");
return false;
}

Expand Down Expand Up @@ -182,9 +188,9 @@ static bool TestStackOverflowLargeFrameSecondaryThread()
List<string> lines;
if (TestStackOverflow("stackoverflow", "largeframe secondary", out lines))
{
if (!lines[lines.Count - 1].EndsWith("at System.Threading.ThreadHelper.ThreadStart()"))
if (!lines.Exists(elem => elem.EndsWith("at TestStackOverflow.Program.Test(Boolean)")))
{
Console.WriteLine("Missing \"System.Threading.ThreadHelper.ThreadStart\" method frame at the last line");
Console.WriteLine("Missing \"TestStackOverflow.Program.Test\" method frame");
return false;
}

Expand Down