Repository navigation
Closed
Description
Description
I'm trying to run a Generic Host application that's stored on the WSL filesystem, from the Windows environment. I expect it to run like a regular console app, but instead I get a StackOverflowException after a few minutes.
Reproduction Steps
WSL
$ mkdir ~/repro
$ cd ~/repro
$ dotnet new worker
Windows command prompt
C:\>dotnet run --project \\wsl.localhost\Ubuntu-24.04\home\[user]\repro\repro.csproj
Expected behavior
info: repro.Worker[0]
Worker running at: 11/09/2025 10:13:55 -05:00
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: /home/jamend/repro
info: repro.Worker[0]
Worker running at: 11/09/2025 10:13:56 -05:00
info: repro.Worker[0]
Worker running at: 11/09/2025 10:13:57 -05:00
...
Actual behavior
System.StackOverflowException
...
[Managed to Native Transition]
System.Private.CoreLib.dll!Interop.Kernel32.GetMessage(int errorCode, nint moduleHandle) Unknown
System.IO.FileSystem.Watcher.dll!System.IO.FileSystemWatcher.Monitor(System.IO.FileSystemWatcher.AsyncReadState state) Unknown
System.IO.FileSystem.Watcher.dll!System.IO.FileSystemWatcher.StartRaisingEvents() Unknown
Microsoft.Extensions.FileProviders.Physical.dll!Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher() Unknown
Microsoft.Extensions.Primitives.dll!Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration<System.Action>.OnChangeTokenFired() Unknown
System.Private.CoreLib.dll!System.Threading.CancellationTokenSource.Register(System.Delegate callback, object stateForCallback, System.Threading.SynchronizationContext syncContext, System.Threading.ExecutionContext executionContext) Unknown
Microsoft.Extensions.Primitives.dll!Microsoft.Extensions.Internal.ChangeCallbackRegistrar.UnsafeRegisterChangeCallback<System.__Canon>(System.Action<object> callback, object state, System.Threading.CancellationToken token, System.Action<System.__Canon> onFailure, System.__Canon onFailureState) Unknown
Microsoft.Extensions.Primitives.dll!Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration<System.Action>.RegisterChangeTokenCallback(Microsoft.Extensions.Primitives.IChangeToken token) Unknown
Microsoft.Extensions.Primitives.dll!Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration<System.__Canon>.OnChangeTokenFired() Unknown
[The 4 frame(s) above this were repeated 3223 times]
...
at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].RegisterChangeTokenCallback(Microsoft.Extensions.Primitives.IChangeToken)
at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnChangeTokenFired()
at System.Threading.CancellationTokenSource.Invoke(System.Delegate, System.Object, System.Threading.CancellationTokenSource)
at System.Threading.CancellationTokenSource.Register(System.Delegate, System.Object, System.Threading.SynchronizationContext, System.Threading.ExecutionContext)
at System.Threading.CancellationToken.Register(System.Delegate, System.Object, Boolean, Boolean)
at System.Threading.CancellationToken.UnsafeRegister(System.Action`1<System.Object>, System.Object)
at Microsoft.Extensions.Internal.ChangeCallbackRegistrar.UnsafeRegisterChangeCallback[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Action`1<System.Object>, System.Object, System.Threading.CancellationToken, System.Action`1<System.__Canon>, System.__Canon)
at Microsoft.Extensions.Primitives.CancellationChangeToken.RegisterChangeCallback(System.Action`1<System.Object>, System.Object)
at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].RegisterChangeTokenCallback(Microsoft.Extensions.Primitives.IChangeToken)
at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnChangeTokenFired()
at System.Threading.CancellationTokenSource.Invoke(System.Delegate, System.Object, System.Threading.CancellationTokenSource)
at System.Threading.CancellationTokenSource.Register(System.Delegate, System.Object, System.Threading.SynchronizationContext, System.Threading.ExecutionContext)
at System.Threading.CancellationToken.Register(System.Delegate, System.Object, Boolean, Boolean)
at System.Threading.CancellationToken.UnsafeRegister(System.Action`1<System.Object>, System.Object)
at Microsoft.Extensions.Internal.ChangeCallbackRegistrar.UnsafeRegisterChangeCallback[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Action`1<System.Object>, System.Object, System.Threading.CancellationToken, System.Action`1<System.__Canon>, System.__Canon)
at Microsoft.Extensions.Primitives.CancellationChangeToken.RegisterChangeCallback(System.Action`1<System.Object>, System.Object)
at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].RegisterChangeTokenCallback(Microsoft.Extensions.Primitives.IChangeToken)
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(System.Func`1<Microsoft.Extensions.Primitives.IChangeToken>, System.Action)
at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(Microsoft.Extensions.Configuration.FileConfigurationSource)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(Microsoft.Extensions.Configuration.IConfigurationBuilder)
at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(Microsoft.Extensions.Configuration.IConfigurationSource)
at Microsoft.Extensions.Configuration.ConfigurationManager.Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(Microsoft.Extensions.Configuration.IConfigurationSource)
at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(Microsoft.Extensions.Configuration.IConfigurationBuilder, System.String, Boolean, Boolean)
at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.ApplyDefaultAppConfiguration(Microsoft.Extensions.Hosting.HostBuilderContext, Microsoft.Extensions.Configuration.IConfigurationBuilder, System.String[])
at Microsoft.Extensions.Hosting.HostApplicationBuilder..ctor(Microsoft.Extensions.Hosting.HostApplicationBuilderSettings)
at Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder(System.String[])
at Program.<Main>$(System.String[])
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Activity
MihuBot commentedon Nov 9, 2025
I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):
cincuranet commentedon Jan 29, 2026
Triage: Might be same root cause as #113855, but this is slightly different: WSL vs. systemd.
Prevent StackOverflow in PhysicalFilesWatcher on unwatchable file sys…