[GRASS-dev] grass7 problems with MASK
Glynn Clements
glynn at gclements.plus.com
Wed Jan 13 15:09:45 EST 2010
Soeren Gebbert wrote:
> 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.
Use an environment variable rather than a GRASS ($GISRC) variable,
e.g.
if (getenv("GRASS_ABORT_ON_ERROR"))
abort();
An abort is preferable to trying to create a segfault, as abort() is
specified by the ANSI/ISO C standard, while generating a segfault
relies upon undefined behaviour (which means that there is no robust
way to force a segfault to occur; the most obvious approach is prone
to being optimised-out).
The default behaviour for SIGABRT is to terminate and dump core, the
same as for SIGSEGV, so I'm not sure that there's any benefit to a
segfault. If you really need SIGSEGV, raise(SIGSEGV) might be better
(but does this signal exist on Windows?).
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list