Closed seisman closed 8 months ago
Also reported in https://github.com/GenericMappingTools/gmt/issues/3157.
When built with add_definitions(/DDO_NOT_EXIT)
it never calls exit
What we need to have is to NEVER call exit
whatever the circumstances are.
I think most of these happen during map_setup where I pass back a bool search variable and was too lazy to change that when a fatal error occurred. I will see how to do this and maybe I can get help from you to extend the solution to other instances. But deep in #3370 but so close to being done.
FYI, here are the number of occurrences of the string GMT_exit in the source codes:
./gmt_api.c: 6
./gmt_fft.c: 2
./gmt_grdio.c: 4
./gmt_init.c: 29
./gmt_io.c: 22
./gmt_map.c: 17
./gmt_memory.c: 3
./gmt_plot.c: 11
./gmt_proj.c: 3
./gmt_regexp.c: 7
./gmt_shore.c: 4
./gmt_sph.c: 14
./gmt_stat.c: 1
./gmt_support.c: 35
./gmtmath.c: 1
./grdblend.c: 4
./img/img2grd.c: 1
./mgd77/mgd77.c: 25
./mgd77/mgd77manage.c: 9
./segy/pssegyz.c: 4
./segy/segy2grd.c: 3
./spectrum1d.c: 1
./sphtriangulate.c: 6
./spotter/grdspotter.c: 1
./spotter/originater.c: 1
./spotter/spotter.c: 14
./x2sys/x2sys.c: 16
./x2sys/x2sys_datalist.c: 4
So no trivial, and clearly not mostly a gmt_map.c problem.
After #3389 we will be down to these:
./gmt_init.c: 29
./gmt_io.c: 22
./gmt_map.c: 17
./gmt_plot.c: 11
./gmt_sph.c: 14
./gmt_support.c: 35
./gmt_types.h: 2
./mgd77/mgd77.c: 25
./spotter/spotter.c: 14
./x2sys/x2sys.c: 16
and the PSL_exit is gone via #3390. I think I can get the remaining ones done for 6.1.
GMT_exit calls are now restricted to mgd77.c
and under the control of add_definitions(/DDO_NOT_EXIT)
so I think this can be safely closed. (reopen if not).
Reported in the PyGMT repository: https://github.com/GenericMappingTools/pygmt/issues/450
The GMT_exit function calls system "exit" function, which works for command line, but also exit external programs (e.g., Python) if
API->do_not_exit
is set tofalse
. Even thoughAPI->do_not_exit
is set totrue
, the GMT library still crashes later, since the fatal error is not correctly handled.