GNOME Bugzilla – Bug 782487
gnome-usage segfaults on open
Last modified: 2017-05-26 12:37:23 UTC
gnome-usage is segfaulting just after is open. Sometimes it segfaults a few seconds after, and some times the moment it is open. This was testing using jhbuild on X11. What I did: 1. Compiled gnome-usage with address sanitizer 2. installed, and opened jhbuild shell 3. ran the command: gnome-usage. I don't think gdb output could be helpfull. I wish gnome-usage was written in C, so that it could be debugged easily and precisely (vala itself seems to have lots of leaks [may be I'm wrong though], so it's hard to do these kind of things right for code written in vala). Any way, asan output: adiq@rose:~/jhbuild/checkout/gnome-usage$ gnome-usage Gtk-Message: Failed to load module "canberra-gtk-module" Gtk-Message: Failed to load module "canberra-gtk-module" ASAN:DEADLYSIGNAL ================================================================= ==28420==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fa1d9d92ca7 bp 0x7fff75825df0 sp 0x7fff75825dd0 T0) #0 0x7fa1d9d92ca6 in g_strdup /home/sadiq/jhbuild/checkout/glib/glib/gstrfuncs.c:362 #1 0x5572fa2e3d58 in usage_system_monitor_get_full_process_cmd /home/sadiq/jhbuild/checkout/gnome-usage/src/system-monitor.vala:233 #2 0x5572fa2e3d58 in usage_system_monitor_update_data /home/sadiq/jhbuild/checkout/gnome-usage/src/system-monitor.vala:129 #3 0x5572fa2e5939 in _usage_system_monitor_update_data_gsource_func /home/sadiq/jhbuild/checkout/gnome-usage/build/system-monitor.c:431 #4 0x7fa1d9d768d3 in g_timeout_dispatch /home/sadiq/jhbuild/checkout/glib/glib/gmain.c:4703 #5 0x7fa1d9d7601d in g_main_dispatch /home/sadiq/jhbuild/checkout/glib/glib/gmain.c:3234 #6 0x7fa1d9d7601d in g_main_context_dispatch /home/sadiq/jhbuild/checkout/glib/glib/gmain.c:3887 #7 0x7fa1d9d76267 in g_main_context_iterate /home/sadiq/jhbuild/checkout/glib/glib/gmain.c:3960 #8 0x7fa1d9d762ec in g_main_context_iteration /home/sadiq/jhbuild/checkout/glib/glib/gmain.c:4021 #9 0x7fa1d97f5fd3 in g_application_run /home/sadiq/jhbuild/checkout/glib/gio/gapplication.c:2381 #10 0x5572fa2a14bd in _vala_main /home/sadiq/jhbuild/checkout/gnome-usage/src/gnome-usage.vala:36 #11 0x5572fa2a14eb in main /home/sadiq/jhbuild/checkout/gnome-usage/src/gnome-usage.vala:21 #12 0x7fa1d805e2b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0) #13 0x5572fa298789 in _start (/media/sadiq/Temp/jhbuild/install/bin/gnome-usage+0x2b789) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /home/sadiq/jhbuild/checkout/glib/glib/gstrfuncs.c:362 in g_strdup ==28420==ABORTING Thanks
Created attachment 351593 [details] [review] system-monitor: Don't read argv beyond the boundary If there are no elements in argv, the first item could be itself null. And thus reading the next item is illegal. So break the loop once null is found. Also as both elements of secure_arguments are required to have some value insert a blank in case null is reached early.
Review of attachment 351593 [details] [review]: Thanks for patch! Only one thing, do you can fix indentation to use 4 spaces please? (I know that somewhere in Usage source code are used tabs and there is a bad offset, I will fix it soon.)
Created attachment 351626 [details] [review] system-monitor: Don't read argv beyond the boundary If there are no elements in argv, the first item could be itself null. And thus reading the next item is illegal. So break the loop once null is found. Also as both elements of secure_arguments are required to have some value insert a blank in case null is reached early.
Eh, sorry, I shall re-attach this again.
Created attachment 351628 [details] [review] system-monitor: Don't read argv beyond the boundary If there are no elements in argv, the first item could be itself null. And thus reading the next item is illegal. So break the loop once null is found. Also as both elements of secure_arguments are required to have some value insert a blank in case null is reached early. I have did untabify around the region I have edited. Hope that would be fine
Review of attachment 351628 [details] [review]: Thanks. Now it is accepted.
Review of attachment 351628 [details] [review]: I commited patch to master branch.