Page 1 of 1

Crash in Mac version of zyGrib

Posted: 28 Jan 2016 20:56
by lsoltero
It seems that on some machines zyGrib crashes on start up when it tries to load and render a grib file that was previously downloaded.

here is stack trace
(gdb) where
#0 GriddedPlotter::draw_CoveredZone (this=0x0, pnt=@0x7fff5fbf99d8, proj=0x101cc9550) at GriddedPlotter.cpp:370
#1 0x0000000100161fd5 in MapDrawer::draw_MeteoData_Gridded (this=0x10b6399c0, pnt=@0x7fff5fbf99d8, proj=0x101cc9550, plotter=0x0) at MapDrawer.cpp:416
#2 0x0000000100161eb9 in MapDrawer::draw_GSHHS_and_GriddedData (this=0x10b6399c0, pntGlobal=@0x7fff5fbf9be8, mustRedraw=true, isEarthMapValid=false, proj=0x101cc9550, plotter=0x0, drawCartouche=true) at MapDrawer.cpp:374
#3 0x00000001001df615 in Terrain::paintEvent (this=0x10b639240) at Terrain.cpp:1086
#4 0x0000000100c00a2e in QWidget::event ()

the following mod to line 1086 in Terrain.cpp fixes the problem

case DATATYPE_MBLUE :
// added to fix crash
if ( griddedPlot == NULL ) {
setCursor(oldcursor);
return;
}
// end of crash fix
drawer->draw_GSHHS_and_GriddedData
(pnt, mustRedraw, isEarthMapValid, proj, griddedPlot, drawCartouche);


it seems that there is some race condition that causes printEvent to be called before the GriddedPlotter data structure is initialized. Depending on the speed of your computer, disk, load, etc the Grid may or may not be loaded before the screen refresh. When this happens the griddedPlot variable is 0. which is an invalid address which causes an exception.

--luis

Re: Crash in Mac version of zyGrib

Posted: 28 Jan 2016 21:41
by lsoltero
here is the patch file. I tried to attache it but keep getting "The extension patch is not allowed" so here it is

Code: Select all

===================================================================
--- Terrain.cpp	(revision 4477)
+++ Terrain.cpp	(working copy)
@@ -1083,6 +1083,10 @@
         switch (currentFileType) {
 			case DATATYPE_GRIB :
 			case DATATYPE_MBLUE :
+			  if ( griddedPlot == NULL ) {
+			    setCursor(oldcursor);
+			    return;
+			  }
 				drawer->draw_GSHHS_and_GriddedData 
 					(pnt, mustRedraw, isEarthMapValid, proj, griddedPlot, drawCartouche);
 				break;

Re: Crash in Mac version of zyGrib

Posted: 14 Feb 2016 09:38
by jza
Hi,
This bug has never been signaled, and I can't reproduce it.
But your correction is very simple, so it will still be implemented in a future version.
Tanks for this participation.