Bug 10205 - System.InvalidOperationException in FileSystemWatcher
Summary: System.InvalidOperationException in FileSystemWatcher
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-11 08:09 UTC by Hylke Bons
Modified: 2015-12-15 13:34 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Hylke Bons 2013-02-11 08:09:22 UTC
This crash in the FileSystemWatcher was reported against my application, but I think this is a bug in Mono.
Orignial report: https://github.com/hbons/SparkleShare/issues/1166

Mono version:

Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-5ubuntu1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  x86
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            Included Boehm (with typed GC and Parallel Mark)


Stacktrace:

Unhandled Exception: System.InvalidOperationException: Hashtable.Enumerator: snapshot out of sync.
  at System.Collections.Hashtable+Enumerator.FailFast () [0x00000] in :0 
  at System.Collections.Hashtable+Enumerator.MoveNext () [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.UpdateDataAndDispatch (System.IO.DefaultWatcherData data, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.StartDispatching (System.IO.FileSystemWatcher fsw) [0x00000] in :0 
  at System.IO.FileSystemWatcher.Start () [0x00000] in :0 
  at System.IO.FileSystemWatcher.set_EnableRaisingEvents (Boolean value) [0x00000] in :0 
  at SparkleLib.SparkleWatcher.Enable () [0x00000] in :0 
  at (wrapper remoting-invoke-with-check) SparkleLib.SparkleWatcher:Enable ()
  at SparkleLib.SparkleRepoBase.SyncUpBase () [0x00000] in :0 
  at SparkleLib.SparkleRepoBase.m__12 () [0x00000] in :0 
  at System.Threading.Thread.StartInternal () [0x00000] in :0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Hashtable.Enumerator: snapshot out of sync.
  at System.Collections.Hashtable+Enumerator.FailFast () [0x00000] in :0 
  at System.Collections.Hashtable+Enumerator.MoveNext () [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.UpdateDataAndDispatch (System.IO.DefaultWatcherData data, Boolean dispatch) [0x00000] in :0 
  at System.IO.DefaultWatcher.StartDispatching (System.IO.FileSystemWatcher fsw) [0x00000] in :0 
  at System.IO.FileSystemWatcher.Start () [0x00000] in :0 
  at System.IO.FileSystemWatcher.set_EnableRaisingEvents (Boolean value) [0x00000] in :0 
  at SparkleLib.SparkleWatcher.Enable () [0x00000] in :0 
  at (wrapper remoting-invoke-with-check) SparkleLib.SparkleWatcher:Enable ()
  at SparkleLib.SparkleRepoBase.SyncUpBase () [0x00000] in :0 
  at SparkleLib.SparkleRepoBase.m__12 () [0x00000] in :0 
  at System.Threading.Thread.StartInternal () [0x00000] in :0
Comment 1 Arsen.Shnurkov 2015-12-02 10:04:34 UTC
Please look, do we have the same bug or a different one - https://github.com/gitextensions/gitextensions/issues/2696
Comment 2 Andres G. Aragoneses 2015-12-03 05:38:36 UTC
Arsen, thanks for the heads up!

And thanks for that new stacktrace, because it's a bit better than the one posted in comment#0, as it has line numbers. I'll paste it here for reference:

Unhandled Exception:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
  at System.Collections.Hashtable+HashtableEnumerator.MoveNext () [0x00018] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/external/referencesource/mscorlib/system/collections/hashtable.cs:1613 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00366] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:283 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.UpdateDataAndDispatch (System.IO.DefaultWatcherData data, Boolean dispatch) [0x00047] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:175 
  at System.IO.DefaultWatcher.Monitor () [0x0008d] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:155 
  at System.Threading.Thread.StartInternal () [0x00016] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/corlib/System.Threading/Thread.cs:696 
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
  at System.Collections.Hashtable+HashtableEnumerator.MoveNext () [0x00018] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/external/referencesource/mscorlib/system/collections/hashtable.cs:1613 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x00366] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:283 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.DoFiles (System.IO.DefaultWatcherData data, System.String directory, Boolean dispatch) [0x0002a] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:198 
  at System.IO.DefaultWatcher.UpdateDataAndDispatch (System.IO.DefaultWatcherData data, Boolean dispatch) [0x00047] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:175 
  at System.IO.DefaultWatcher.Monitor () [0x0008d] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/System/System.IO/DefaultWatcher.cs:155 
  at System.Threading.Thread.StartInternal () [0x00016] in /var/calculate/tmp/portage/dev-lang/mono-9999/work/mono-9999/mcs/class/corlib/System.Threading/Thread.cs:696 


Thanks to this info, I created a pull request to fix this issue:

https://github.com/mono/mono/pull/2285
Comment 3 Andres G. Aragoneses 2015-12-10 01:40:50 UTC
Pull request has been merged, can anyone mark this as FIXED? Thanks
Comment 4 Alexander Köplinger [MSFT] 2015-12-15 13:34:14 UTC
Done.

Note You need to log in before you can comment on or make changes to this bug.