Opened 12 years ago

Last modified 8 years ago

#1598 new defect

Exit call in some libs

Reported by: volter Owned by: grass-dev@…
Priority: normal Milestone: 6.4.6
Component: Default Version: 6.4.2
Keywords: shared lib Cc:
CPU: Unspecified Platform: Unspecified

Description

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

Change History (2)

in reply to:  description comment:1 by glynn, 12 years ago

Replying to 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 digfrealloc() should just use G_realloc()).

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

comment:2 by neteler, 8 years ago

Milestone: 6.4.36.4.6
Note: See TracTickets for help on using tickets.