GNOME Bugzilla – Bug 682950
GFileMonitor crashing on high event count when running in different thread
Last modified: 2012-10-06 14:42:20 UTC
Created attachment 222782 [details] testcase in C language Hello I'm trying to monitor a folder and it's decendant folders with GFileMonitor in a thread seperate from the main thread. A high number of events leads to a crash in the program. I set up a testcase in C so it is possible to reproduce the problem. To trigger the crash, I used a media player called xnoise: It has a function to scan a directory (in this case the music folder) with Taglib. Taglib accesses the files in -rw mode, so a lot of G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT signals are created. In my case ~600 folders are scanned. At some point my testcase program crashes. Strange is that the crash can be avoided, if some prints are added to the signal handler. Output in gdb: Program received signal SIGSEGV, Segmentation fault.
+ Trace 230755
Thread 140737317189376 (LWP 8582)
4101 in /build/buildd/glib2.0-2.32.3/./gobject/gtype.c (gdb) Running the program in Valgrind with G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --log-file=vgdump ./testcase doesn't trigger the crash in the testcase.
This is a total disappointment! As usually nobody ever reacts on a bug report. No confirmation, no fixes no questions. It's always the same. I could also write a bug report on a piece of paper and throw it out of the window. I am willing to help but as usually I am locked out.
sorry, that's just how free software is; the only way to guarantee a bug gets fixed is to fix it yourself. In particular, there are some parts of glib that no one really "owns", so bugs filed against them aren't going to get looked at right away...
Created attachment 225881 [details] [review] GFileMonitor: thread-safety fix for non-default-main-context monitors When queuing events to another thread, we need a mutex around priv->pending_file_changes and priv->pending_file_change_source.
Thank you for taking care of this! I almost gave up.
Review of attachment 225881 [details] [review]: This looks correct.
Attachment 225881 [details] pushed as 7e6fa55 - GFileMonitor: thread-safety fix for non-default-main-context monitors