Skip to content

System.IO.FileSystem.Watcher.Tests Fails with Open File Descriptors Limit Reached when TestReadyToRun is Enabled #96728

Closed

Description

@ivdiazsa

Description

When building and running System.IO.FileSystem.Watcher.Tests with TestReadyToRun=true, the test run will crash and fail with an error message about the limit of open file descriptors allowed.

Reproduction Steps

  1. Clone the repo and build the clr and libs subsets. Make sure you specify TestReadyToRun, so that some necessary pretest components get built.
git clone https://github.com/dotnet/runtime
cd runtime
./build.sh --subset clr+libs --configuration Release -p:TestReadyToRun=true
  1. If PR Add ActiveIssue Annotations to Failing TestReadyToRun Tests and Reenable the Executables #96721 has been merged when investigating this issue, then first reenable the test by removing its ActiveIssue annotation in src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Move.cs:
// Comment this one out --> [ActiveIssue("https://github.com/dotnet/runtime/issues/96728", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]
private void FileMove_FromWatchedToUnwatched(WatcherChangeTypes eventType)
{
    string dir_watched = CreateTestDirectory(TestDirectory, "dir_watched");
    string dir_unwatched = CreateTestDirectory(TestDirectory, "dir_unwatched");
    string testFile = CreateTestFile(dir_watched, "file");
    using (var watcher = new FileSystemWatcher(dir_watched, "*"))
    {
        string sourcePath = testFile; // watched
        string targetPath = Path.Combine(dir_unwatched, "file");

        Action action = () => File.Move(sourcePath, targetPath);
        Action cleanup = () => File.Move(targetPath, sourcePath);

        ExpectEvent(watcher, eventType, action, cleanup, sourcePath);
    }
}
  1. Build and run the test
cd src/libraries/System.IO.FileSystem.Watcher/tests
/path/to/runtime/dotnet.sh build -c Release -t:Test -p:TestReadyToRun=true

Expected behavior

All tests pass, except the skipped ones.

Actual behavior

Test fails with the following error, making the whole run fail:

========================= Begin custom configuration settings ==============================
export __TestArchitecture=x64
export __IsXUnitLogCheckerSupported=1
========================== End custom configuration settings ===============================
----- start Tue Jan 9 03:36:03 PM PST 2024 =============== To repro directly: =====================================================
pushd /path/to/runtime/artifacts/bin/System.IO.FileSystem.Watcher.Tests/Release/net9.0-linux/publish
chmod +rwx System.IO.FileSystem.Watcher.Tests ^&^& ./System.IO.FileSystem.Watcher.Tests -notrait category=OuterLoop -notrait category=failing -xml testResults.xml 
popd
===========================================================================================================
/path/to/runtime/artifacts/bin/System.IO.FileSystem.Watcher.Tests/Release/net9.0-linux/publish /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests
Running assembly:System.IO.FileSystem.Watcher.Tests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
[FAIL] System.IO.Tests.File_NotifyFilter_Tests.FileSystemWatcher_File_NotifyFilter_LastWriteTime(filter: LastWrite)
System.IO.IOException : The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.Tests.FileSystemWatcherTest.ExecuteAndVerifyEvents(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Boolean assertExpected, String[] expectedPaths, Int32 timeout) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 308
   at System.IO.Tests.FileSystemWatcherTest.ExpectEvent(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Action cleanup, String[] expectedPaths, Int32 attempts, Int32 timeout) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 198
   at System.IO.Tests.File_NotifyFilter_Tests.FileSystemWatcher_File_NotifyFilter_LastWriteTime(NotifyFilters filter) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.NotifyFilter.cs:line 136
   at InvokeStub_File_NotifyFilter_Tests.FileSystemWatcher_File_NotifyFilter_LastWriteTime(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.IO.Tests.Directory_NotifyFilter_Tests.FileSystemWatcher_Directory_NotifyFilter_Attributes(filter: Size)
System.IO.IOException : The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.Tests.FileSystemWatcherTest.ExecuteAndVerifyEvents(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Boolean assertExpected, String[] expectedPaths, Int32 timeout) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 308
   at System.IO.Tests.FileSystemWatcherTest.ExpectEvent(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Action cleanup, String[] expectedPaths, Int32 attempts, Int32 timeout) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 198
   at System.IO.Tests.Directory_NotifyFilter_Tests.<>c__DisplayClass4_0.<FileSystemWatcher_Directory_NotifyFilter_Attributes>b__0() in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.Directory.NotifyFilter.cs:line 46
   at System.IO.Tests.FileSystemWatcherTest.Execute(Action test, Int32 maxAttempts, Func`2 backoffFunc, Predicate`1 retryWhen, String testName) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 238
   at InvokeStub_Directory_NotifyFilter_Tests.FileSystemWatcher_Directory_NotifyFilter_Attributes(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.IO.Tests.WaitForChangedTests.NonZeroTimeout_NoEvents_TimesOut(enabledBeforeWait: True, useTimeSpan: True)
System.IO.IOException : The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.Tests.WaitForChangedTests.NonZeroTimeout_NoEvents_TimesOut(Boolean enabledBeforeWait, Boolean useTimeSpan) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.WaitForChanged.cs:line 113
   at InvokeStub_WaitForChangedTests.NonZeroTimeout_NoEvents_TimesOut(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[FAIL] System.IO.Tests.File_Move_Tests.Linux_File_Move_To_Different_Watched_Directory
System.IO.IOException : The configured user limit (128) on the number of inotify instances has been reached, or the per-process limit on the number of open file descriptors has been reached.
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.Tests.FileSystemWatcherTest.ExecuteAndVerifyEvents(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Boolean assertExpected, String[] expectedPaths, Int32 timeout) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 308
   at System.IO.Tests.FileSystemWatcherTest.ExpectEvent(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Action cleanup, String[] expectedPaths, Int32 attempts, Int32 timeout) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs:line 198
   at System.IO.Tests.File_Move_Tests.FileMove_DifferentWatchedDirectory(WatcherChangeTypes eventType) in /path/to/runtime/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.File.Move.cs:line 184
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Finished System.IO.FileSystem.Watcher.Tests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

Regression?

No

Known Workarounds

Keep the test disabled so that the other tests in the run can be executed unaffected.

Activity

  1. added
    disabled-test
    on Jan 9, 2024
  2. added this to the Future milestone on Jan 9, 2024
  3. tmds commented on Mar 12, 2026

    @tmds
    Member

    #117148 will help reduce contention on inotify instances. It will definitely impact the amount of inotify instances used while running the tests.

  4. locked and limited conversation to collaborators on Apr 11, 2026
  5. jkotas commented on Jul 1, 2026

    @jkotas
    Member

    Tests are still disabled against this issue

    [ActiveIssue("https://github.com/dotnet/runtime/issues/96728", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]

  6. reopened this on Jul 1, 2026
  7. unlocked this conversation on Jul 1, 2026
  8. added
    in-pr
    on Jul 1, 2026
  9. modified the milestones: Future, 11.0.0 on Jul 1, 2026
  10. locked and limited conversation to collaborators on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOdisabled-testin-prtest-failure

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions