#1055624 viking: Segmentation fault when quitting viking

Package:
viking
Source:
viking
Description:
GPS data editor, analyzer and viewer
Submitter:
Vincent Lefevre
Date:
2023-12-04 01:24:03 UTC
Severity:
normal
Tags:
#1055624#5
Date:
2023-11-08 23:50:24 UTC
From:
To:
I got a segmentation fault when I quit viking:

[...]
(viking:45727): GLib-GObject-WARNING **: 00:24:41.116: invalid unclassed pointer in cast to 'VikLayer'

(viking:45727): GLib-GObject-WARNING **: 00:24:41.116: invalid unclassed pointer in cast to 'GtkWidget'

(viking:45727): Gtk-CRITICAL **: 00:24:41.116: gtk_widget_get_toplevel: assertion 'GTK_IS_WIDGET (widget)' failed
zsh: segmentation fault (core dumped)  viking velov-7008-7031-8.gpx

In gdb:

[...]
Core was generated by `viking velov-7008-7031-8.gpx'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  unlink_chunk (p=p@entry=0x55e7b438b860, av=0x7f011f06fc60 <main_arena>)
    at ./malloc/malloc.c:1628
1628    ./malloc/malloc.c: No such file or directory.
[Current thread is 1 (Thread 0x7f011c3d5180 (LWP 45727))]

I'ved attached the full backtrace.

#1055624#10
Date:
2023-11-09 07:49:50 UTC
From:
To:
Hi,

Thanks. I have forwarded the issue upstream.

Paul

#1055624#17
Date:
2023-12-04 01:20:17 UTC
From:
To:
Control: tags -1 upstream fixed-upstream patch

I've attached a patch. This is the upstream patch by Rob Norris

https://github.com/viking-gps/viking/commit/21ecac2

which I ported for viking 1.10 in Debian 12:

* 2 hunks were rejected in src/vikmapslayer.c due to changes in
  reindented code (I just had to re-add the "if").

* the compilation was failing due to undefined variable dr,
  so I just had to take the current code at this point, giving
  this simple change in src/vikmapslayer.c:

+        DownloadResult_t dr = DOWNLOAD_NOT_REQUIRED;
         if (need_download) {
-          DownloadResult_t dr = vik_map_source_download( MAPS_LAYER_NTH_TYPE(mdi->maptype), &(mdi->mapcoord), mdi->filename_buf, handle);
+          dr = vik_map_source_download( MAPS_LAYER_NTH_TYPE(mdi->maptype), &(mdi->mapcoord), mdi->filename_buf, handle);

I've done several tests, and everything is now fine on my machine.