John McCue <[email protected]> writes:
> Hi
>
> I installed port gkrellmreminder-2.0.0p10 and it causes
> gkrellm to core dump.
>
> I took the reminder package from
> http://gkrellm.srcbox.net/Plugins.html and fixed it.
>
> I had to add include "#include <sys/param.h>"
> and add " || defined(OpenBSD)" to the checks of the two
> define lines in "reminder.c". Since that change reminder
> plugin is working fine on my system (see below).
>
> My changes are in this source package, I used RCS to keep
> track of the changes made.
>
> https://jmcunx.com/data/gkrellm-reminder-2.0.2-jmc.tar.gz
> https://jmcunx.com/data/gkrellm-reminder-2.0.2-jmc.sha256
Hello,
When reporting bugs please include a recipe to reproduce the issue. In
this case, for me is installing grkellm and grkellmreminder, launching
gkrellm, enabling the plugin (left click on the bar, then plugins),
click on the reminder widget, schedule an event and press "Add" and then
"Apply".
Since it's a crash due to a SIGSEGV a backtrace would be useful. It
doesn't generate a coredump thought, and the program doesn't contain
debug symbols so even if ran inside egdb (pkg_add gdb) there aren't much
info.
I've added DEBUG_PACKAGES=${BUILD_PACKAGES} to the plugin' Makefile and
re-built the port, which generates a debug- package with the info.
Armed with that, the bug was easy to spot:
reminder.c:1259 strftime( ..., localtime (&event->end ) );
(gdb) p event->end
$1 = -2314885534574444544
(gdb) p/x event->end
$2 = 0xdfdfdfdf00000000
localtime returns NULL and then it crashes in strftime (_fmt to be precise.)
at first I thought of a possible use-after-free, given the 0xdf pattern,
but the rest of the struct seems fine:
(gdb) p *event
$3 = {name = 0xe7905a9cd10 "foo", id = 1641634627, days = 1, occurs = 0,
start = 281476618345276, end = -2314885534574444544,
last_displayed = 15908559728384, next = 0x0}
However, the compiler complains loudly because the program loves to
fscanf with %d into time_t. Fixing those seems to fix the crash too,
but it's just a minimal diff, the code is very fragile.
Regarding your fix for the 2038-year, I'm not sure what the consequences
of this are.
- adj_year = gtk_adjustment_new( 0, 1971, 2037, 1, 10, 0 );
+ adj_year = gtk_adjustment_new( 0, 1971, 9999, 1, 10, 0 );
so i've left it out. I've not studied in much detail the plugin, but it
seems to "just" create a bunch of time_t using the gtk form and
serialize/deserialize those to a text file. Hopefully it doesn't need
any further special treatment. (The other changes were superfluous
because you added `|| defined(__OpenBSD)' to lines that already had that
check.)
I don't really use gkrellm (just discovered it today!), so please test
the following diff and see if it fixes the problem for you too. I've
left the DEBUG_PACKAGES in case it still crashes.
As a final note, if you want to share a diff please use cvs or git/got.
Posting a diff is not required when reported bugs, but if you worked on
one at least make it easier for who'll look at it by generating it
against the port tree. You can fetch the port tree using cvs[0] or with
git using the github mirror[1].
[0]: https://www.openbsd.org/anoncvs.html
[1]: https://github.com/openbsd/ports
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/sysutils/gkrellm/plugins/reminder/Makefile,v
retrieving revision 1.23
diff -u -p -r1.23 Makefile
--- Makefile 15 Sep 2017 15:37:18 -0000 1.23
+++ Makefile 8 Jan 2022 10:00:02 -0000
@@ -5,7 +5,7 @@ COMMENT= GKrellM2 will remind you to do
V= 2.0.0
DISTNAME= gkrellm-reminder-${V}
PKGNAME= gkrellmreminder-${V}
-REVISION= 10
+REVISION= 11
CATEGORIES= misc
HOMEPAGE=
http://members.dslextreme.com/users/billw/gkrellm/Plugins.html\#REMINDER
@@ -15,5 +15,7 @@ MASTER_SITES= http://members.dslextreme.
EXTRA_WANTLIB= gthread-2.0
PLUGIN= ${WRKSRC}/reminder.so
+
+DEBUG_PACKAGES= ${BUILD_PACKAGES}
.include <bsd.port.mk>
Index: patches/patch-reminder_c
===================================================================
RCS file:
/home/cvs/ports/sysutils/gkrellm/plugins/reminder/patches/patch-reminder_c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-reminder_c
--- patches/patch-reminder_c 3 Nov 2003 20:34:18 -0000 1.1.1.1
+++ patches/patch-reminder_c 8 Jan 2022 10:01:06 -0000
@@ -1,6 +1,7 @@
$OpenBSD: patch-reminder_c,v 1.1.1.1 2003/11/03 20:34:18 sturm Exp $
---- reminder.c.orig 2002-12-04 06:29:09.000000000 +0100
-+++ reminder.c 2003-11-02 16:42:30.000000000 +0100
+Index: reminder.c
+--- reminder.c.orig
++++ reminder.c
@@ -87,7 +87,7 @@ static struct reminder_config {
struct event_stored {
@@ -15,20 +16,22 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
current->name = g_strdup(buffer);
- if( fscanf( fp, "%u %d %d %ld %ld %ld\n", ¤t->id, ¤t->days,
-+ if( fscanf( fp, "%lu %d %d %d %d %d\n", ¤t->id, ¤t->days,
++ if( fscanf( fp, "%lu %d %d %lld %lld %lld\n", ¤t->id,
¤t->days,
¤t->occurs, ¤t->start, ¤t->end,
¤t->last_displayed ) != 6 )
{
-@@ -431,7 +431,7 @@ reminder_save_stored()
+@@ -431,8 +431,8 @@ reminder_save_stored()
current = head_stored;
while( current )
{
- fprintf( fp, "%s\n%u %d %d %ld %ld %ld\n", current->name, current->id,
current->days,
-+ fprintf( fp, "%s\n%lu %d %d %d %d %d\n", current->name, current->id,
current->days,
- current->occurs, current->start, current->end,
current->last_displayed );
+- current->occurs, current->start, current->end,
current->last_displayed );
++ fprintf( fp, "%s\n%lu %d %d %lld %lld %lld\n", current->name,
current->id, current->days,
++ current->occurs, (long long)current->start, (long
long)current->end, current->last_displayed );
current = current->next;
-@@ -529,7 +529,7 @@ reminder_remove_event_stored( struct eve
+ }
+@@ -529,7 +529,7 @@ reminder_remove_event_stored( struct event_stored **he
}
static struct event_stored *
@@ -63,7 +66,7 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
/* Try to remove event from temp list. If not, add to to-be-deleted list */
if( !reminder_remove_event_stored( &head_temp, id ) )
-@@ -1661,13 +1661,13 @@ cb_sort_days( GtkCList *clist, gconstpoi
+@@ -1661,13 +1661,13 @@ cb_sort_days( GtkCList *clist, gconstpointer *p1, gcon
struct event_stored *es1, *es2;
@@ -81,7 +84,7 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
if( es1 && es2 )
{
-@@ -1692,13 +1692,13 @@ cb_sort_time( GtkCList *clist, gconstpoi
+@@ -1692,13 +1692,13 @@ cb_sort_time( GtkCList *clist, gconstpointer *p1, gcon
struct event_stored *es1, *es2;
@@ -99,7 +102,7 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
if( es1 && es2 )
return( ( ( es1->start - TIMEZONE_DIFF ) % SECS_PER_DAY ) -
-@@ -1715,13 +1715,13 @@ cb_sort_start( GtkCList *clist, gconstpo
+@@ -1715,13 +1715,13 @@ cb_sort_start( GtkCList *clist, gconstpointer *p1, gco
struct event_stored *es1, *es2;
@@ -117,7 +120,7 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
if( es1 && es2 )
return es1->start - es2->start;
-@@ -1737,13 +1737,13 @@ cb_sort_end( GtkCList *clist, gconstpoin
+@@ -1737,13 +1737,13 @@ cb_sort_end( GtkCList *clist, gconstpointer *p1, gcons
struct event_stored *es1, *es2;
@@ -144,7 +147,7 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
/* delete event from today */
num_active--;
-@@ -2914,7 +2914,7 @@ reminder_window_never( GtkWidget *window
+@@ -2914,7 +2914,7 @@ reminder_window_never( GtkWidget *window, gpointer dat
static void
reminder_window_later( GtkWidget *window, gpointer data )
{
@@ -153,7 +156,7 @@ $OpenBSD: patch-reminder_c,v 1.1.1.1 200
struct event_stored *new, *old;
/* delete event from today */
-@@ -2991,7 +2991,7 @@ reminder_window_later( GtkWidget *window
+@@ -2991,7 +2991,7 @@ reminder_window_later( GtkWidget *window, gpointer dat
static void
reminder_window_dismiss( GtkWidget *window, gpointer data )
{