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 574722 - gnome-system-log crashed with g_date_valid failure when loading the empty log files.
gnome-system-log crashed with g_date_valid failure when loading the empty log...
Status: RESOLVED WONTFIX
Product: gnome-system-log
Classification: Core
Component: general
git master
Other All
: Normal critical
: ---
Assigned To: gnome-system-log-maint
gnome-system-log-maint
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2009-03-10 08:21 UTC by vivian
Modified: 2020-09-26 09:40 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26



Description vivian 2009-03-10 08:21:34 UTC
Steps to reproduce:
1. Open gnome-system-log
2. Click boot.log or others which is a empty log file
Notes: this issue only occurs when displaying empty log files.


Stack trace:
Application failure message 1:
Program: /usr/sbin/gnome-system-log
Type: Segmentation fault.
[New process 1587]
[New process 1585]
  • #0 g_date_valid
    from /lib/libglib-2.0.so.0
  • #0 g_date_valid
    from /lib/libglib-2.0.so.0
  • #1 gtk_box_pack_end
  • #2 gtk_box_pack_end
  • #3 ??
    from /lib/libgio-2.0.so.0
  • #4 ??
    from /lib/libglib-2.0.so.0
  • #5 ??
    from /lib/libglib-2.0.so.0
  • #6 start_thread
    at pthread_create.c line 297
  • #7 clone
    at ../sysdeps/unix/sysv/linux/i386/clone.S line 130


Other information:
Try to debug the issue , found that in log_read_dates(), date was set to 0x40, a invalid value, then cause the crash. 
It seems that when buffer_lines[0] == NULL, the date will not be set the valid value. 
Initial date to NULL (GDate *date = NULL) in log_read_dates() can avoid the issue.
Comment 1 Cosimo Cecchi 2009-05-23 13:22:07 UTC
Does this still happen for you with gnome-system-log >= 2.26.x?
Comment 2 David H. Gutteridge 2009-08-05 02:22:39 UTC
Hello,

I'm seeing a similar error with 2.26.0, the test case is the same:
simply try to open an empty log file, in my case "lpd-errs", and we get
a segfault.  This should be duplicable with any empty file, just go
to /var/log or somewhere else appropriate and touch(1) a test file.

My trace is different, it's as follows:

(gdb) bt
  • #0 g_date_valid
    from /usr/pkg/lib/libglib-2.0.so.0
  • #1 log_read_dates
    at logview-utils.c line 164
  • #2 do_read_new_lines
    at logview-log.c line 209
  • #3 g_io_scheduler_push_job
    from /usr/pkg/lib/libgio-2.0.so.0
  • #4 g_thread_pool_push
    from /usr/pkg/lib/libglib-2.0.so.0
  • #5 g_thread_create_full
    from /usr/pkg/lib/libglib-2.0.so.0
  • #6 pthread_create
    from /usr/lib/libpthread.so.0
  • #7 swapcontext
    from /usr/lib/libc.so.12
  • #0 g_date_valid
    from /usr/pkg/lib/libglib-2.0.so.0
  • #1 log_read_dates
    at logview-utils.c line 164
  • #2 do_read_new_lines
    at logview-log.c line 209
  • #3 g_io_scheduler_push_job
    from /usr/pkg/lib/libgio-2.0.so.0
  • #4 g_thread_pool_push
    from /usr/pkg/lib/libglib-2.0.so.0
  • #5 g_thread_create_full
    from /usr/pkg/lib/libglib-2.0.so.0
  • #6 pthread_create
    from /usr/lib/libpthread.so.0
  • #7 swapcontext
    from /usr/lib/libc.so.12

The problem seems to be that we have a test (at the top of
log_read_dates()) like so:

g_return_val_if_fail (buffer_lines != NULL, NULL);

...so we're checking if buffer_lines itself is a valid pointer, but
there's no test to ensure that buffer_lines actually points at any
valid strings.  My quick and dirty fix is trivial:

--- logview-utils.c~    2008-12-23 09:55:03.000000000 -0500
+++ logview-utils.c     2009-08-04 19:20:04.000000000 -0400
@@ -143,6 +143,7 @@
   gboolean done = FALSE;
 
   g_return_val_if_fail (buffer_lines != NULL, NULL);
+  g_return_val_if_fail (*buffer_lines != NULL, NULL);
 
   n = g_strv_length ((char **) buffer_lines);
 
@@ -274,4 +275,4 @@
   days = g_slist_sort (days, days_compare);
 
   return days;

This changes a segfault into an assertion, viz.:

(gnome-system-log:2250): gnome-system-log-CRITICAL **: log_read_dates: assertion `*buffer_lines != NULL' failed

I didn't have time to dig further into the code, but I imagine a more
elegant way around this might be done wherever buffer_lines was first
built up: if there are no input lines for it to point to, it should be
reset to NULL.

Regards,

Dave
Comment 3 David H. Gutteridge 2009-08-05 03:04:15 UTC
I should add, the original reporter is correct that setting the "date"
variable to NULL when it's initially created will also fix the problem
here, but "buffer_lines" is the ultimate culprit, and similar
assumptions about it may be relevant for other functions in the present
or future.

Dave
Comment 4 Tobias Mueller 2010-03-29 23:18:54 UTC
Reopening as the requested information has been provided.
Comment 5 André Klapper 2020-09-26 09:40:49 UTC
gnome-system-log is not under active development anymore and had its last code changes more than four years ago. Its codebase has been archived at https://gitlab.gnome.org/Archive/gnome-system-log/

Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect
reality. Please feel free to reopen this ticket (or rather transfer the project
to GNOME Gitlab, as GNOME Bugzilla is being shut down) if anyone takes the
responsibility for active development again.