[GRASS-dev] [GRASS GIS] #1598: Exit call in some libs

#1598: Exit call in some libs
-------------------------+--------------------------------------------------
Reporter: volter | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.3
Component: Default | Version: 6.4.2
Keywords: shared lib | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Some of the Grass libraries call exit. Probably you can do something about
it!

rpmlint -I shared-lib-calls-exit
shared-lib-calls-exit:
This library package calls exit() or _exit(), probably in a non-fork()
context. Doing so from a library is strongly discouraged - when a library
function calls exit(), it prevents the calling program from handling the
error, reporting it to the user, closing files properly, and cleaning up
any
state that the program has. It is preferred for the library to return an
actual error code and let the calling program decide how to handle the
situation.

grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_linkm.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_edit.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_sim.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_dig2.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_raster.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_interpdata.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_dbmidriver.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_display.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_sqlp.so.6.4.2 exit@GLIBC_2.2.5
grass-libs.x86_64: W: shared-lib-calls-exit
/usr/lib64/libgrass_cdhc.so.6.4.2 exit@GLIBC_2.2.5

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1598&gt;
GRASS GIS <http://grass.osgeo.org>

#1598: Exit call in some libs
-------------------------+--------------------------------------------------
Reporter: volter | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.3
Component: Default | Version: 6.4.2
Keywords: shared lib | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(by glynn):

Replying to [ticket:1598 volter]:
> Some of the Grass libraries call exit. Probably you can do something
about it!
The standard error-handling mechanism in GRASS is to call G_fatal_error(),
which calls exit(). Most other libraries probably shouldn't be calling
exit() directly, but should be calling G_fatal_error() instead.

FWIW, the list of library files which call exit() directly is:
{{{
lib/linkm/oom.c
lib/iostream/ami_stream.cpp
lib/vector/diglib/allocation.c
lib/db/dbmi_driver/driver.c
lib/form/open.c
lib/raster3d/maskfn.c
lib/rst/data/dataquad.c
lib/gis/parser_help.c
lib/gis/error.c
lib/gis/parser.c
lib/gis/gisinit.c
lib/driver/init.c
}}}
plus most of the CDHC library.

libgrass_sqlp's exit() is from yy_fatal_error(), which is part of the lex
boilerplate. If desired, error handling can be customised by defining the
macro YY_FATAL_ERROR.

Some of the above are legitimate, others may indicate code which should be
calling G_fatal_error() instead.

lib/vector/diglib/allocation.c uses G_calloc(), so it doesn't need to
perform its own error handling (although dig__frealloc() should just use
G_realloc()).

The other cases should be examined, but most of these are invalid/wontfix.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1598#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>