Skip to content

NetworkAddressChanged event hangs process on Mac #31152

@ryanbrandenburg

Description

@ryanbrandenburg

Repro steps

  1. Install 3.0 RTM
  2. dotnet new console
  3. Replace Program.cs with the following:
using System;

namespace MacMinimal
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) => {
                
            };
        }
    }
}

Expected Result

The process should exit.

Actual Result

The process does not exit.

Details

Thread dumps indicate that this line is the problem:

https://github.com/dotnet/corefx/blob/d3911035f2ba3eb5c44310342cc1d654e42aa316/src/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkAddressChange.OSX.cs#L184

We believe that this Thread should be marked as background so it doesn't block the process exiting.

Real world cases

We found this when we noticed that applications which use AppInsights don't close when they would normally exit on a Mac. This isn't noticed normally because the normal workflow for AspNetCore apps is that when you want the server to exit you send Ctrl-C.

CC @danmosemsft @karelz @davidfowl

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions