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

FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails #53366

Open
Tracked by #64596
runfoapp bot opened this issue May 27, 2021 · 10 comments
Open
Tracked by #64596

FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails #53366

runfoapp bot opened this issue May 27, 2021 · 10 comments

Comments

@runfoapp
Copy link

runfoapp bot commented May 27, 2021

Started today.

Runfo Tracking Issue: FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails

Build Definition Kind Run Name

Build Result Summary

Day Hit Count Week Hit Count Month Hit Count
0 0 0
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label May 27, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@aik-jahoda aik-jahoda changed the title Tracking issue in runtime name:FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails May 27, 2021
@aik-jahoda aik-jahoda changed the title name:FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails May 27, 2021
@aik-jahoda
Copy link
Contributor

There is massive occurrence of failures, disabling the test. cc @jozkee

@ghost
Copy link

ghost commented May 28, 2021

Tagging subscribers to this area: @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

Started today.

Runfo Tracking Issue: FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails

Build Definition Kind Run Name Console Core Dump Test Results Run Client
1159666 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159666 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159634 runtime PR 53347 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159634 runtime PR 53347 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159605 runtime PR 52708 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159605 runtime PR 52708 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159597 runtime PR 53171 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159597 runtime PR 53171 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159451 runtime PR 53144 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159451 runtime PR 53144 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159444 runtime PR 53344 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159444 runtime PR 53344 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159416 runtime PR 53343 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159416 runtime PR 53343 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159354 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159354 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159329 runtime PR 53287 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159329 runtime PR 53287 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159282 runtime PR 53338 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159282 runtime PR 53338 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159218 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159218 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159200 runtime PR 53231 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159200 runtime PR 53231 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159168 runtime PR 50510 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159168 runtime PR 50510 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159135 runtime PR 53338 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159135 runtime PR 53338 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159110 runtime PR 53220 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159110 runtime PR 53220 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159065 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159065 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159053 runtime PR 53336 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159053 runtime PR 53336 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159024 runtime PR 53035 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159024 runtime PR 53035 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159009 runtime PR 53334 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1159009 runtime PR 53334 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158999 runtime PR 53331 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158999 runtime PR 53331 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158954 runtime PR 47640 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158954 runtime PR 47640 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158923 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158923 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158902 runtime PR 52802 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158902 runtime PR 52802 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158877 runtime PR 53331 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158877 runtime PR 53331 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158808 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158808 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158731 runtime PR 53301 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158731 runtime PR 53301 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158661 runtime PR 53171 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158661 runtime PR 53171 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158600 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158600 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158590 runtime PR 52258 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158590 runtime PR 52258 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158531 runtime PR 53248 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158531 runtime PR 53248 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158511 runtime PR 53315 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158511 runtime PR 53315 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158511 runtime PR 53315 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158511 runtime PR 53315 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158511 runtime PR 53315 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158511 runtime PR 53315 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158398 runtime PR 53250 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158398 runtime PR 53250 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158368 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158368 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158315 runtime PR 53257 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158315 runtime PR 53257 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158239 runtime PR 53253 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158239 runtime PR 53253 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158131 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158131 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158042 runtime PR 53197 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158042 runtime PR 53197 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158003 runtime PR 53231 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1158003 runtime PR 53231 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157990 runtime PR 53301 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157990 runtime PR 53301 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157809 runtime PR 51998 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157809 runtime PR 51998 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157770 runtime PR 53253 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157770 runtime PR 53253 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157757 runtime Rolling net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157757 runtime Rolling net6.0-windows-Release-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157744 runtime PR 47640 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157744 runtime PR 47640 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157738 runtime PR 52870 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157738 runtime PR 52870 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157666 runtime PR 53294 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157666 runtime PR 53294 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157625 runtime PR 53290 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157625 runtime PR 53290 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157589 runtime PR 53289 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157589 runtime PR 53289 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157583 runtime PR 53288 net6.0-windows-Release-x86-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py
1157583 runtime PR 53288 net6.0-windows-Debug-x64-CoreCLR_checked-Windows.10.Amd64.Open console.log runclient.py

Displaying 100 of 106 results

Build Result Summary

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

area-System.IO, untriaged

Milestone: -

@adamsitnik
Copy link
Member

@jozkee would it be possible to re-enable the test and fix it when you'll be working on other issues related to symbolic links and FileSystemWatcher?

@adamsitnik
Copy link
Member

@jozkee @carlossanlop were you able to identify the source of the problem? Is this a product bug and we should fix it in 6.0? Or a flaky test and 7.0 should be fine?

@jozkee jozkee modified the milestones: 6.0.0, 7.0.0 Aug 11, 2021
@carlossanlop
Copy link
Member

The issue is old enough that the failure results disappeared, so I can't be certain where the failure was happening. What I do know is that these new tests were added before the new symlink APIs were introduced, so it has its own logic to create unit tests, which may not be working correctly in Windows 10 if Developer Mode is not enabled. So there are two things that can be changed to ensure the tests are more reliable:

  • Add the attribute to the method that verifies if we can create symlinks.
  • Instead of using its own symlink creation logic, use the new APIs. This passes:
public void FileSystemWatcher_DirectorySymbolicLink_TargetsFile_Fails()
{
    // Arrange
    using var tempDir = new TempDirectory(GetTestFilePath());

    string pathToTarget = Path.Join(tempDir.Path, Path.GetRandomFileName());

    var dirLink = new DirectoryInfo(Path.Join(tempDir.Path, Path.GetRandomFileName()));
    dirLink.CreateAsSymbolicLink(pathToTarget); // Create a dir link to a non-existent target (valid scenario)

    var targetFile = new FileInfo(pathToTarget);
    targetFile.Create().Dispose(); // Create the target as a file

    using var watcher = new FileSystemWatcher(dirLink.FullName);

    // Act - Assert
    Assert.Throws<FileNotFoundException>(() => watcher.EnableRaisingEvents = true);
}

@adamsitnik
Copy link
Member

@carlossanlop could you please send the PR with proposed changes?

@jozkee
Copy link
Member

jozkee commented Aug 23, 2021

@carlossanlop This doesn't fail on creating the symlink. It fails when a directory symlink pointing to a file is passed to the FSW and EnableRaisingEvents is set. This test was already differing with 7 and 8.1, and this tells to me that it also differs with multiple Win10 versions.

I suggest we just remove the test since it is asserting what I think is windows undefined behavior, the undefined behavior is: "Open a directory symlink pointing to a file with CreateFileW".

@adamsitnik
Copy link
Member

"Open a directory symlink pointing to a file with CreateFileW".

@jozkee is my understanding correct that the problem is that we might open a file (not a directory), using the following logic?

// Create handle to directory being monitored
_directoryHandle = Interop.Kernel32.CreateFile(
lpFileName: _directory,
dwDesiredAccess: Interop.Kernel32.FileOperations.FILE_LIST_DIRECTORY,
dwShareMode: FileShare.Read | FileShare.Delete | FileShare.Write,
dwCreationDisposition: FileMode.Open,
dwFlagsAndAttributes: Interop.Kernel32.FileOperations.FILE_FLAG_BACKUP_SEMANTICS | Interop.Kernel32.FileOperations.FILE_FLAG_OVERLAPPED);

If that is the case, we might want to verify if it's possible to enforce CreateFileW to open only directories. I remember that NtCreateFile was exposing FILE_DIRECTORY_FILE flag that would allow to open only directories. It seems that there is some magical way of doing that with CreateFileW as well: https://stackoverflow.com/a/55361521/5852046

@jozkee
Copy link
Member

jozkee commented Aug 25, 2021

The problem is that _directoryHandle is not always considered an invalid handle for the case of a Directory Symbolic Link that points to a file (symlink-directory -> foo.txt).
I don't follow on your suggestion, how can we enforce that CreateFileW throws if the specified path is not a directory? Can you point me explicitly which flag we need to pass to the sys-call?

@carlossanlop carlossanlop added the untriaged New issue has not been triaged by the area owner label Mar 23, 2023
@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants