Skip to content
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

System.IO.FileSystem.Watcher.Tests crashing on MacCatalyst #65601

Closed
runfoapp bot opened this issue Feb 18, 2022 · 7 comments · Fixed by #68010
Closed

System.IO.FileSystem.Watcher.Tests crashing on MacCatalyst #65601

runfoapp bot opened this issue Feb 18, 2022 · 7 comments · Fixed by #68010
Labels
arch-arm64 area-System.IO help wanted [up-for-grabs] Good issue for external contributors os-maccatalyst MacCatalyst OS runtime-mono specific to the Mono runtime
Milestone

Comments

@runfoapp
Copy link

runfoapp bot commented Feb 18, 2022

Seems to be in FileSystemWatcher_Directory_Create_InNestedDirectory:

Test collection for System.IO.Tests.Directory_Create_Tests
2022-02-18 09:37:11.786663-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: 	[PASS] System.IO.Tests.Directory_Create_Tests.FileSystemWatcher_Directory_PathNotExists
2022-02-18 09:37:11.793323-0800  localhost fseventsd[81]: (libsystem_info.dylib) Created Activity ID: 0x234d6, Description: Resolve user group list
2022-02-18 09:37:11.805998-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: 
Unhandled Exception:
Xunit.Sdk.ContainsException: Assert.Contains() Failure
Not found: /var/folders/62/ftpn5pv523j8xsdw56s9jnp40000gs/T/Directory_Create_Tests_hsm4w3hg.os4/FileSystemWatcher_Directory_Create_InNestedDirectory_53_bb03705a/dir1
In value:  String[] ["/var/folders/62/ftpn5pv523j8xsdw56s9jnp40000gs/T/D"...]
   at Xunit.Assert.Contains[String](String expected, IEnumerable`1 collection, IEqualityComparer`1 comparer) in /_/src/xunit.assert/Asserts/CollectionAsserts.cs:line 245
   at Xunit.Assert.Contains[String](String expected, IEnumerable`1 collection) in /_/src/xunit.assert/Asserts/CollectionAsserts.cs:line 226
   at System.IO.Tests.FileSystemWatcherTest.<>c__DisplayClass9_0.<WatchCreated>b__0(Object o, FileSystemEventArgs e)
   at System.IO.FileSystemWatcher.InvokeOn(FileSystemEventArgs e, FileSystemEventHandler handler)
   at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(WatcherChangeTypes changeType, ReadOnlySpan`1 name)
   at System.IO.FileSystemWatcher.RunningInstance.Process<…>
2022-02-18 09:37:11.806440-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: (CoreAnalytics) [com.apple.CoreAnalytics:client] Entering exit handler.
2022-02-18 09:37:11.806442-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: (CoreAnalytics) [com.apple.CoreAnalytics:client] Exiting exit handler.

Runfo Tracking Issue: System.IO.FileSystem.Watcher.Tests crashing on MacCatalyst

Build Definition Kind Run Name Console Core Dump Test Results Run Client
1713622 runtime-extra-platforms PR 67861 net7.0-MacCatalyst-Release-arm64-Mono_Release-OSX.1100.Arm64.Open console.log runclient.py
1711428 runtime-extra-platforms PR 67861 net7.0-MacCatalyst-Release-arm64-Mono_Release-OSX.1100.Arm64.Open console.log runclient.py

Build Result Summary

Day Hit Count Week Hit Count Month Hit Count
0 2 2
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.IO untriaged New issue has not been triaged by the area owner labels Feb 18, 2022
@ghost
Copy link

ghost commented Feb 18, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Runfo Creating Tracking Issue (data being generated)

Author: runfoapp[bot]
Assignees: -
Labels:

area-System.IO, untriaged

Milestone: -

@elinor-fung elinor-fung added os-maccatalyst MacCatalyst OS runtime-mono specific to the Mono runtime labels Feb 19, 2022
@ghost
Copy link

ghost commented Feb 19, 2022

Tagging subscribers to 'os-maccatalyst': @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

Issue Details
Test collection for System.IO.Tests.Directory_Create_Tests
2022-02-18 09:37:11.786663-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: 	[PASS] System.IO.Tests.Directory_Create_Tests.FileSystemWatcher_Directory_PathNotExists
2022-02-18 09:37:11.793323-0800  localhost fseventsd[81]: (libsystem_info.dylib) Created Activity ID: 0x234d6, Description: Resolve user group list
2022-02-18 09:37:11.805998-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: 
Unhandled Exception:
Xunit.Sdk.ContainsException: Assert.Contains() Failure
Not found: /var/folders/62/ftpn5pv523j8xsdw56s9jnp40000gs/T/Directory_Create_Tests_hsm4w3hg.os4/FileSystemWatcher_Directory_Create_InNestedDirectory_53_bb03705a/dir1
In value:  String[] ["/var/folders/62/ftpn5pv523j8xsdw56s9jnp40000gs/T/D"...]
   at Xunit.Assert.Contains[String](String expected, IEnumerable`1 collection, IEqualityComparer`1 comparer) in /_/src/xunit.assert/Asserts/CollectionAsserts.cs:line 245
   at Xunit.Assert.Contains[String](String expected, IEnumerable`1 collection) in /_/src/xunit.assert/Asserts/CollectionAsserts.cs:line 226
   at System.IO.Tests.FileSystemWatcherTest.<>c__DisplayClass9_0.<WatchCreated>b__0(Object o, FileSystemEventArgs e)
   at System.IO.FileSystemWatcher.InvokeOn(FileSystemEventArgs e, FileSystemEventHandler handler)
   at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(WatcherChangeTypes changeType, ReadOnlySpan`1 name)
   at System.IO.FileSystemWatcher.RunningInstance.Process<…>
2022-02-18 09:37:11.806440-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: (CoreAnalytics) [com.apple.CoreAnalytics:client] Entering exit handler.
2022-02-18 09:37:11.806442-0800  localhost System.IO.FileSystem.Watcher.Tests[3577]: (CoreAnalytics) [com.apple.CoreAnalytics:client] Exiting exit handler.

Runfo Tracking Issue: System.IO.FileSystem.Watcher.Tests crashing on MacCatalyst

Build Definition Kind Run Name Console Core Dump Test Results Run Client
1621547 runtime-extra-platforms Rolling net7.0-MacCatalyst-Release-arm64-Mono_Release-OSX.1100.Arm64.Open console.log runclient.py
1620950 runtime-extra-platforms PR 65551 net7.0-MacCatalyst-Release-arm64-Mono_Release-OSX.1100.Arm64.Open console.log runclient.py
1620484 runtime-extra-platforms PR 65506 net7.0-MacCatalyst-Release-arm64-Mono_Release-OSX.1100.Arm64.Open console.log runclient.py

Build Result Summary

Day Hit Count Week Hit Count Month Hit Count
3 3 3
Author: runfoapp[bot]
Assignees: -
Labels:

area-System.IO, untriaged, runtime-mono, os-maccatalyst

Milestone: -

@adamsitnik
Copy link
Member

It can be related to #64906, but since it was very defensive change I expect it to expose an existing problem rather than introduce a new one.

@tmds when working on #64906 (and #57139) have you tried to figure out why the directory was getting removed in the meantime? I wonder if we have a test bug somewhere (deleting the directories before the tests finishes).

@tmds
Copy link
Member

tmds commented Feb 21, 2022

have you tried to figure out why the directory was getting removed in the meantime? I wonder if we have a test bug somewhere (deleting the directories before the tests finishes).

The ContentRoot of that test is /tmp so it observes removal of directories from other tests.

var appSettingsPath = Path.Combine(Path.GetTempPath(), "appsettings.json");
string SaveRandomConfig()
{
var newMessage = $"Hello ASP.NET Core: {Guid.NewGuid():N}";
File.WriteAllText(appSettingsPath, $"{{ \"Hello\": \"{newMessage}\" }}");
return newMessage;
}
var dynamicConfigMessage1 = SaveRandomConfig();
using var host = Host.CreateDefaultBuilder()
.UseContentRoot(Path.GetDirectoryName(appSettingsPath))

@adamsitnik
Copy link
Member

The ContentRoot of that test is /tmp so it observes removal of directories from other tests.

So the long term fix would be to ensure that each test is using it's own directory?

@tmds
Copy link
Member

tmds commented Feb 21, 2022

So the long term fix would be to ensure that each test is using it's own directory?

Yes, tests are supposed to have their own directories so they work independent.
In this particular case, not following the pattern uncovered a bug in FileSystemWatcher.Linux.

adamsitnik added a commit to adamsitnik/runtime that referenced this issue Feb 21, 2022
@adamsitnik adamsitnik added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Feb 21, 2022
adamsitnik added a commit that referenced this issue Feb 22, 2022
* move duplicated logic to a method

* ensure all paths are logged, so we can diagnose #65601

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
@adamsitnik adamsitnik added help wanted [up-for-grabs] Good issue for external contributors and removed needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration labels Mar 14, 2022
@adamsitnik adamsitnik added this to the 7.0.0 milestone Mar 14, 2022
@jozkee
Copy link
Member

jozkee commented Apr 14, 2022

After @adamsitnik's PR, we got the following call stack:

Unhandled Exception:
Xunit.Sdk.XunitException: Expected path(s):
/var/folders/fj/y8c6bwk94s58rwndssrlh8ch0000gq/T/Directory_Create_Tests_wy2khfpv.tuf/FileSystemWatcher_Directory_Create_InNestedDirectory_53_057b6691/dir1/nested/dir
Actual path: /var/folders/fj/y8c6bwk94s58rwndssrlh8ch0000gq/T/Directory_Create_Tests_wy2khfpv.tuf/FileSystemWatcher_Directory_Create_InNestedDirectory_53_057b6691/dir1
   at System.IO.Tests.FileSystemWatcherTest.VerifyExpectedPaths(String[] expectedPaths, FileSystemEventArgs e)
   at System.IO.Tests.FileSystemWatcherTest.<>c__DisplayClass10_0.<WatchCreated>b__0(Object o, FileSystemEventArgs e)
   at System.IO.FileSystemWatcher.InvokeOn(FileSystemEventArgs e, FileSystemEventHandler handler)
   at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(WatcherChangeTypes changeType, ReadOnlySpan`1 name)
   at System.IO.FileSystemWatcher.RunningInstance.ProcessEvents(Int32 numEvents, Byte** eventPaths, Span`1 eventFlags, Span`1 eventIds, FileSystemWatcher watcher)
   at System.<…>

We were expecting ./dir1/nested/dir but got the first directory created in the test, which matches with what's described here:

// Remove Created events as there is racecondition when create dir and then observe parent folder. It receives Create event altought Watcher is not registered yet.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Apr 14, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Apr 14, 2022
@ghost ghost locked as resolved and limited conversation to collaborators May 14, 2022
@jozkee jozkee removed their assignment Mar 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm64 area-System.IO help wanted [up-for-grabs] Good issue for external contributors os-maccatalyst MacCatalyst OS runtime-mono specific to the Mono runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants