[GRASS-dev] grass7 problems with MASK
Soeren Gebbert
soerengebbert at googlemail.com
Wed Jan 13 11:09:28 EST 2010
Hi,
i have had the same problem and implemented an identical solution.
But the problem was hard to figure out, because G_fatal_error() is now called
if opening or closing of maps fails.
The problem appeared when i started r.sim.water after creating a mask.
So i searched the error first in r.sim.water, because i changed the
memory allocation
recently and enabled the compilation of this module.
After a while i implemented an artificial segfault in G_fatal_error()
to enable debugging with gdb and valgrind and found the problem.
Therefor i would like to suggest to establish an environmental
variable to enable
G_fatal_error() to segfault for better error debugging. I was thinking
of a variable
in gisrc, but this will result in an infinite G_fatal_error()
call-loop, because G_fatal_error() is called in case the environmental
variable is not present in gisrc.
What would be the best way to implement such an behavior of G_fatal_error()?
Any suggestions are welcome.
Best
Soeren
2010/1/13 Markus Metz <markus.metz.giswork at googlemail.com>:
> Because of r40217, Rast_close() and Rast_unopen() can no longer be called
> unconditionally. That gives me errors when a MASK is present:
> ERROR: Invalid descriptor: 0
>
> The following patch to lib/raster works for me but I'm not sure if this is
> the right way
>
> Index: init.c
> ===================================================================
> --- init.c (revision 40418)
> +++ init.c (working copy)
> @@ -83,6 +83,7 @@
>
> /* Set masking flag unknown */
> R__.auto_mask = -1;
> + R__.mask_fd = -1;
>
> R__.nbytes = sizeof(CELL);
> R__.compression_type = getenv("GRASS_INT_ZLIB") ? 2 : 1;
> Index: auto_mask.c
> ===================================================================
> --- auto_mask.c (revision 40418)
> +++ auto_mask.c (working copy)
> @@ -61,7 +61,9 @@
> return 0;
> }
>
> - Rast_unopen(R__.mask_fd);
> + if (R__.mask_fd >= 0)
> + Rast_unopen(R__.mask_fd);
> + R__.mask_fd = Rast__open_old("MASK", G_mapset());
> if (R__.mask_fd < 0) {
> R__.auto_mask = 0;
>
> Alternatively, just return if a raster map can't be unopened/closed?
>
> Markus M
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
More information about the grass-dev
mailing list