After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 782487 - gnome-usage segfaults on open
gnome-usage segfaults on open
Status: RESOLVED FIXED
Product: gnome-usage
Classification: Other
Component: general
unspecified
Other Linux
: Normal critical
: ---
Assigned To: GNOME Usage maintainer(s)
GNOME Usage maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-05-11 02:28 UTC by Mohammed Sadiq
Modified: 2017-05-26 12:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
system-monitor: Don't read argv beyond the boundary (1.18 KB, patch)
2017-05-11 02:51 UTC, Mohammed Sadiq
none Details | Review
system-monitor: Don't read argv beyond the boundary (1.18 KB, patch)
2017-05-11 13:15 UTC, Mohammed Sadiq
none Details | Review
system-monitor: Don't read argv beyond the boundary (1.27 KB, patch)
2017-05-11 13:19 UTC, Mohammed Sadiq
committed Details | Review

Description Mohammed Sadiq 2017-05-11 02:28:38 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
Comment 1 Mohammed Sadiq 2017-05-11 02:51:59 UTC
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.
Comment 2 Petr Štětka 2017-05-11 12:41:04 UTC
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.)
Comment 3 Mohammed Sadiq 2017-05-11 13:15:17 UTC
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.
Comment 4 Mohammed Sadiq 2017-05-11 13:17:02 UTC
Eh, sorry, I shall re-attach this again.
Comment 5 Mohammed Sadiq 2017-05-11 13:19:08 UTC
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
Comment 6 Petr Štětka 2017-05-11 13:53:38 UTC
Review of attachment 351628 [details] [review]:

Thanks. Now it is accepted.
Comment 7 Petr Štětka 2017-05-26 12:35:48 UTC
Review of attachment 351628 [details] [review]:

I commited patch to master branch.