[GRASS-dev] g.mapsets -l crash (sometimes)

Markus Neteler neteler at osgeo.org
Sun Apr 12 15:28:17 EDT 2009


Hi,

when running g.mapsets -l on a Linux box, I get segfault:

...
terra_lst1km20080610.LST_Night.84144 terra_lst1km20090105.LST_Day.82812
aqua_lst1km20080827.LST_Night.85210 terra_lst1km20080709.LST_Day.84201
terra_lst1km20080628.LST_Night.84180 aqua_lst1km20080630.LST_Night.85102
terra_lst1km20080703.LST_Day.84189 terra_lst1km20080720.LST_Night.84222
terra_lst1km20090108.LST_Day.82818 aqua_lst1km20080730.LST_Night.85159
terra_lst1km20080718.LST_Night.84218 aqua_lst1km20080621.LST_Day.85085
aqua_lst1km20090228.LST_Night.82801 aqua_lst1km20090219.LST_Night.82783
terra_lst1km20090105.LST_Night.84656 aqua_lst1km20080829.LST_Day.83596
aqua_lst1km20080830.LST_Night.85216 aqua_lst1km20090228
segmentation violation

It appears that 'Path' in main_cmd.c is empty.

Consider the following patch:

svn diff general/g.mapsets/
Index: general/g.mapsets/main_cmd.c
===================================================================
--- general/g.mapsets/main_cmd.c        (revision 36680)
+++ general/g.mapsets/main_cmd.c        (working copy)
@@ -184,7 +184,13 @@
        goto DISPLAY;
     }

-    /* note I'm assuming that mapsets cannot have ' 's in them */
+    /* preset Path if empty */
+    if(strlen(Path) == 0){
+       strcat(Path, "PERMANENT");
+       strcat(Path, " ");
+       strcat(Path, G_mapset());
+    }
+    /* note I'm assuming that mapset names cannot have ' 's in them */
     tokens = G_tokenize(Path, " ");

which appears to cue the problem (crash in strcmp() below because
tokens is empty.

Objections?

Markus


More information about the grass-dev mailing list