Skip to content

Runaway inotify watches with HostApplicationBuilder #126708

@Dash

Description

@Dash

When using Microsoft.Extensions.Hosting v10.0.5 (other versions not checked), and leveraging CreateApplicationBuilder on Linux, all directories in the current working tree are iterated and inotify watches created.

This can create a startup performance delay, and additionally present a denial-of-service risk as inotify watches can be easily exhausted.

I have only checked this on openSUSE Leap 15.6 6.4.0-150600.23.87-default.

Steps to reproduce:

  1. Create a project (dotnet new console)
  2. Add Microsoft.Extensions.Hosting (dotnet package add)
  3. Add the extensive code below:
_ = Host.CreateApplicationBuilder();
  1. Build (optimisations don't seem to have an impact as I first noticed this on a aot single-file program)
  2. Run from a suitably lofty parent working directory and check inotify watches

Helpful troubleshooting

Running your built program with 'strace' you should be able to see heaps of inotify_add_watch() function calls spewing forth.
Adding a Console.ReadLine() and then using a script to analyse inotify watches is another way of seeing the impact compared to the rest of your system.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions