Bug 14781 - Application crashes when FileSystemWatcher Changed event handler shows a form
Summary: Application crashes when FileSystemWatcher Changed event handler shows a form
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-09-16 14:35 UTC by mvassilev
Modified: 2018-03-13 14:16 UTC (History)
2 users (show)

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

The whole sln (5.52 KB, application/zip)
2013-09-16 14:35 UTC, mvassilev

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description mvassilev 2013-09-16 14:35:09 UTC
Created attachment 4902 [details]
The whole sln

Hi guys, sorry if this is the wrong section.

I want my application to listen for an assembly change and I want to get a notification (using Gtk.MessageDialog) when the assembly is changed. So I am using the FileSystemWatcher but when the MessageDialog is invoked the application crashes.

This is the application code:

System.IO.FileSystemWatcher watcher = new System.IO.FileSystemWatcher();
watcher.Path = System.IO.Path.GetTempPath();
watcher.NotifyFilter = System.IO.NotifyFilters.CreationTime | System.IO.NotifyFilters.LastWrite;
watcher.EnableRaisingEvents = true;
// The app crashes no matter if the nxt line is commented or not
//watcher.SynchronizingObject = this as System.ComponentModel.ISynchronizeInvoke;

watcher.Changed += delegate(object sender, System.IO.FileSystemEventArgs e) {
  var msgBox = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal, Gtk.MessageType.Info,
                                     Gtk.ButtonsType.Ok, "File Created in the temp");

And when the Gtk.MessageDialog is invoked the application crashes with the following:


  at (wrapper managed-to-native) Gtk.Application.gtk_main () <IL 0x0000e, 0xffffffff>
  at Gtk.Application.Run () <IL 0x00000, 0x0002f>
  at FileSystemWatcherTest.MainClass.Main (string[]) [0x00011] in /home/mvassilev/workspace/Experimental/FileSystemWatcherTest/FileSystemWatcherTest/Main.cs:13
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	/usr/bin/mono() [0x4916ba]
	/usr/bin/mono() [0x4e0d4f]
	/usr/bin/mono() [0x41bc77]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7f6bdff6dcb0]
	/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0(gdk_window_set_geometry_hints+0x4) [0x7f6bda243054]
	/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(+0x25fb63) [0x7f6bda6e6b63]
	/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(+0xfeca) [0x7f6bd8756eca]
	/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit_valist+0x421) [0x7f6bd876f741]
	/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0(g_signal_emit+0x82) [0x7f6bd8770242]
	/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(+0xb8a40) [0x7f6bda53fa40]
	/usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0(+0x1dd56) [0x7f6bda1f2d56]
	/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x133) [0x7f6bd8499d53]
	/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x480a0) [0x7f6bd849a0a0]
	/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_loop_run+0x6a) [0x7f6bd849a49a]
	/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0(gtk_main+0xa7) [0x7f6bda5bb2f7]

Debug info from gdb:

Could not attach to process.  If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user.  For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No threads.

Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
Comment 1 Marek Safar 2018-03-13 14:16:01 UTC
It should be fixed in Mono master

If the issue still persists please include the version information and change the bug status to NEW.