GNOME Bugzilla – Bug 742560
Crash in terminal_screen_has_foreground_process()
Last modified: 2015-01-08 13:37:42 UTC
https://bugzilla.redhat.com/show_bug.cgi?id=1179515 Program terminated with signal SIGSEGV, Segmentation fault.
+ Trace 234526
The code is gsize len; [...] g_snprintf (filename, sizeof (filename), "/proc/%d/cmdline", fgpid); if (!g_file_get_contents (filename, &data, &len, NULL)) return TRUE; [...] for (i = 0; i < len - 1; i++) { if (data[i] == '\0') data[i] = ' '; } My only guess is that g_file_get_contents() doesn't include the trailing \0 in len, and the file is empty. So len is 0 and is unsigned, len-1 is freaking huge, hence the loop runs wild. Does this make sense?
Created attachment 294069 [details] [review] Fix Indeed len doesn't include the extra trailing '\0'. Sometimes /proc/xx/cmdline is terminated by '\0' (most of the processes for me), sometimes it isn't (e.g. /proc/1/cmdline is "/sbin/init" without trailing '\0' for me, shipped by upstart). So I think the best is to prepare for both cases.
Comment on attachment 294069 [details] [review] Fix Committed to master and 3-14.