GNOME Bugzilla – Bug 574722
gnome-system-log crashed with g_date_valid failure when loading the empty log files.
Last modified: 2020-09-26 09:40:49 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]
+ Trace 213313
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.
Does this still happen for you with gnome-system-log >= 2.26.x?
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
+ Trace 216789
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
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
Reopening as the requested information has been provided.
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.