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 167969 - [PATCH] gnome-system log may crash at startup plus leaks memory
[PATCH] gnome-system log may crash at startup plus leaks memory
Status: RESOLVED FIXED
Product: gnome-utils
Classification: Deprecated
Component: logview
2.9.x
Other FreeBSD
: High critical
: ---
Assigned To: gnome-utils Maintainers
gnome-utils Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-02-20 18:35 UTC by Joe Marcus Clarke
Modified: 2005-03-02 15:35 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
Fix crash and memory leak in gnome-system-log (637 bytes, patch)
2005-02-20 18:36 UTC, Joe Marcus Clarke
none Details | Review
Fix memory leak in gnome-system-log (320 bytes, patch)
2005-02-24 02:08 UTC, Joe Marcus Clarke
committed Details | Review

Description Joe Marcus Clarke 2005-02-20 18:35:15 UTC
Steps to reproduce:
1. Launch gnome-system-log
2. 
3. 


Stack trace:
% gdb gnome-system-log

(gdb) r
Starting program: /usr/X11R6/bin/gnome-system-log

Program received signal SIGSEGV, Segmentation fault.

Thread 1 (LWP 100137)

  • #0 strstr
    from /lib/libc.so.5
  • #1 IA__g_strsplit
    at gstrfuncs.c line 2183
  • #2 OpenLogFile
    at logrtns.c line 232
  • #3 logview_create_window_open_file
    at logview.c line 235
  • #4 main
    at logview.c line 307
  • #0 strstr
    from /lib/libc.so.5
  • #1 IA__g_strsplit
    at gstrfuncs.c line 2183
  • #2 OpenLogFile
    at logrtns.c line 232
  • #2 OpenLogFile
    at logrtns.c line 232
  • #3 logview_create_window_open_file
    at logview.c line 235
  • #4 main
    at logview.c line 307

Other information:
The crash is not 100% reproducible, but the problem is with
gnome_vfs_read_entire_file().  It returns a string buffer without the
terminating NUL byte.  This causes funky things to happen.  While looking at
this, I noticed that buffer itself was never freed.  My attached patch corrects
the crash, and fixes the buffer leak.  As a pleasant side-effect,
gnome-system-log now reports correctly formatted log data.
Comment 1 Joe Marcus Clarke 2005-02-20 18:35:50 UTC
This is gnome-utils 2.9.91.
Comment 2 Joe Marcus Clarke 2005-02-20 18:36:24 UTC
Created attachment 37708 [details] [review]
Fix crash and memory leak in gnome-system-log
Comment 3 Vincent Noel 2005-02-20 21:17:51 UTC
Shouldn't the bug in gnome-vfs be filed against gnome-vfs ?
If this really fixes a crash, you can commit now, until the good fix is 
actually in gnome-vfs. The g_free part I have no problem with, thanks !

If you could file the appropriate bug against gnome-vfs that would be really 
nice (and put this new bug as a dependency of the present bug would rock even 
more...)

Once you committed your patch, don't close this present bug - we'll close it 
once it's fixed on the gnome-vfs part. Please correct me if I'm wrong.
Comment 4 Joe Marcus Clarke 2005-02-20 21:22:59 UTC
Well, the memory leak is definitely a logview problem.  I also thing
gnome_vfs_read_entire_file() is operating as designed.  No where in the API
documentation does it say it will return a NUL-terminated string buffer.  I
think this question is best left up to Alex.

As for committing this, I really think it should be done in logview now, as you
say.  However, I'm not a committer, so someone with write access to the repo
will need to do this.

In the meantime, I'll run this by Alex, and update the bug as necessary.
Comment 5 Joe Marcus Clarke 2005-02-21 23:02:37 UTC
I got a reply from Alex:

From: Alexander Larsson <alexl@redhat.com>
> You're right that currently, as designed, read_entire_file doesn't nul
> terminate the buffer. However, maybe we should change it to do so, since
> g_file_get_contents() does this. I can see this being useful in many
> cases.

I've written up a patch for gnome-vfs, and sent it to him.  Given that, the NUL
hack to logview can probably wait.
Comment 6 Joe Marcus Clarke 2005-02-24 02:00:04 UTC
Alex committed the fix to gnome_vfs_read_entire_file(), so all that's left to do
for logview is commit the memory leak portion of the patch.  Thanks!
Comment 7 Joe Marcus Clarke 2005-02-24 02:08:48 UTC
Created attachment 37869 [details] [review]
Fix memory leak in gnome-system-log
Comment 8 Vincent Noel 2005-03-01 18:33:35 UTC
Sorry, it seems like I missed the deadline for code freeze... :(
Comment 9 Kjartan Maraas 2005-03-01 18:47:59 UTC
Nobody's stopping you from submitting this for inclusion in 2.10.0. Just mail
release-team@gnome.org and ask for permission...
Comment 10 Vincent Noel 2005-03-02 15:35:02 UTC
Ok, this is in now. Thanks !