-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add null check for WaitInfo #49628
Add null check for WaitInfo #49628
Conversation
I think the problem is caused by Thread constructors that throw exceptions before being fully initialized. Consider:
|
src/libraries/System.Private.CoreLib/src/System/Threading/WaitSubsystem.Unix.cs
Outdated
Show resolved
Hide resolved
If the issue is the constructor, I don't understand why it would be flaky. I guess it's because most of the time the finalizer won't run before the runtime as a whole gets shut down? This should at least be easy to test. |
Looks like you're right: using System;
using System.Threading;
namespace HelloWorld
{
internal class Program
{
private static void Main(string[] args)
{
try {
new Thread((ThreadStart)null);
}
catch {}
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine("done");
}
}
} I didn't even consider that finalizers are run in C# if the constructor throws... too used to C++. I guess in that case the null check is fine, and I'll move it as suggested. Thanks! |
99dd4c5
to
91f3560
Compare
Failure is #49569 |
Fixes #49583