Search

FileSystemWatcher overlapped listener raising an exception on malformed notifications by Luc Habert

Active

2
0
Sign in
to vote
Type: Bug
ID: 780775
Opened: 3/6/2013 4:41:01 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
Our software uses a FileSystemWatcher. At a customer of our's, the watcher's listener systematically raises the following exception (caught through AppDomain.CurrentDomain.UnhandledException):

System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
at System.IO.FileSystemWatcher.MatchPattern(String relativePath)
at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPointer)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

I found out that the FILE_NOTIFY_INFORMATION structures received (and probably sent by their network file server which I know nothing about) are malformed: the FileNameLength includes the terminating null character, which, I guess, ends up in the path processed by CheckInvalidPathChars.

This is definitely a bug of the file server, but I think it wouldn't hurt if the file system watcher was a bit defensive with respect to the contents of the notifications. It's a very painful problem, because there is no way to catch the exception: it occurs in a filesystemwatcher listener called directly by .NET's guts. When we catch it in AppDomain.UnhandledException, all we can do is pop up a message explaining that our app is going to close.

Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling Version

Visual Studio 2012

Steps to reproduce

Unfortunately, it's hard to reproduce since you need a buggy file server. I would say create a FILE_NOTIFY_INFORMATION struct where the FileNameLength field is too long by one and the FileName has a trailing ^@, and somehow feed it to System.IO.FileSystemWatcher.CompletionStatusChanged.

Product Language

English

Operating System

Windows Vista

Operating System Language

English (UK)

Actual results

The following exception is received in AppDomain.CurrentDomain.UnhandledException

System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
at System.IO.FileSystemWatcher.MatchPattern(String relativePath)
at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPointer)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

when malformed FILE_NOTIFY_INFORMATION are received by a System.IO.FileSystemWatcher.

Expected results

ignoring malformed notifications, perhaps raising a catchable error
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 3/27/2013 at 11:12 AM
Thank you for your feedback. Unfortunately, we are not able to reproduce the issue. Thus, I'm resolving it as "Not Repro", but feel free to reactivate with more information.

Regards,
Immo Landwerth
.NET Framework team
Posted by Microsoft on 3/7/2013 at 1:06 AM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 3/6/2013 at 4:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.