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
Markus,
If, for some reason, Path is empty, nchoices should be 0 and you should
be fine. Also, PERMANENT and G_mapset can be intentionally removed from
search list.
I think Path buffer (4096 bytes) can be flooded because your mapset
names are long. If you used just the -l flag without any other flags or
options, the number of mapsets also matters. The mapset_name array can
contain up to 256 (GMAPSET_MAX) mapset names. In fact, GMAPSET_MAX is
not the maximum number of mapsets, but the maximum length of the mapset
name.
I think these buffers should be dynamically allocated.
Huidae
On Sun, Apr 12, 2009 at 09:28:17PM +0200, Markus Neteler wrote:
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
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev
Huidae, all
(I have removed unused code in 6.40.svn and 6.5.svn to
simplify patching)
On Mon, Apr 13, 2009 at 5:42 AM, Huidae Cho <grass4u@gmail.com> wrote:
Markus,
If, for some reason, Path is empty, nchoices should be 0 and you should
be fine. Also, PERMANENT and G_mapset can be intentionally removed from
search list.
ok (I thought that PERMANENT is a must) - my hack was obviously
incorrect.
I think Path buffer (4096 bytes) can be flooded because your mapset
names are long.
Yes - I have at least 128 of these long names (running elaborations
on a cluster).
If you used just the -l flag without any other flags or
options, the number of mapsets also matters. The mapset_name array can
contain up to 256 (GMAPSET_MAX) mapset names. In fact, GMAPSET_MAX is
not the maximum number of mapsets, but the maximum length of the mapset
name.
No good indeed - There can easily be more than 256 mapsets.
I think these buffers should be dynamically allocated.
I have seen the trunk patch and locally backported it to 6.4.0svn
(my production environment). Works well, thanks! I'll send the patch to
you for 6.5.svn. If there are no objections, I'll then backport it to
6.4.0svn after a period of more testing.
Markus
On Mon, Apr 13, 2009 at 8:55 AM, Markus Neteler <neteler@osgeo.org> wrote:
...
I think these buffers should be dynamically allocated.
I have seen the trunk patch and locally backported it to 6.4.0svn
(my production environment). Works well, thanks! I'll send the patch to
you for 6.5.svn. If there are no objections, I'll then backport it to
6.4.0svn after a period of more testing.
Backported to 6.4.0svn after testing.
Markus