Tatsuro MATSUOKA
2017-02-28 01:38:04 UTC
This is related to bug #1913.
In stdfn.c
there stated
/* Calls the cleanup functions registered using gp_atexit().
* Normally gnuplot should be exited using gp_exit(). In some cases, this is not
* possible (notably when returning from main(), where some compilers get
* confused because they expect a return statement at the very end. In that
* case, gp_exit_cleanup() should be called before the return statement.
*/
*****************************
Normally gnuplot should be exited using gp_exit().
***************************
However, quick test by gdb
gdb gnuplot
b gp_exit_cleanup
b gp_exit
b debug_exit_handler
r
At gnuplot prompt
gnuplot> exit
gdb tells that gnuplot does not end by gp_exit but by debug_exit_handler.
by exit command value of exit_handlers
On cygwin
Breakpoint 1, gp_exit_cleanup () at ../../gnuplot/src/stdfn.c:440
440 {
(gdb) n
[New Thread 8120.0x26b8]
447 while (exit_handlers) {
(gdb) n
449 (*handler->function)();
(gdb) n
[New Thread 8120.0x27cc]
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
447 while (exit_handlers) {
(gdb) n
449 (*handler->function)();
(gdb) n
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
447 while (exit_handlers) {
(gdb) n
454 }
(gdb) n
main (argc=<optimized out>, argv=<optimized out>)
at ../../gnuplot/src/plot.c:694
694 return exit_status;
(gdb) n
695 }
(gdb) n
0x61007acf in cygwin_exit_return () from /usr/bin/cygwin1.dll
(gdb) c
Continuing.
Breakpoint 3, debug_exit_handler () at ../../gnuplot/src/stdfn.c:461
461 if (exit_handlers) {
(gdb) p exit_handlers
$1 = (struct EXIT_HANDLER *) 0x0
(gdb) c
Continuing.
[Thread 8120.0x1708 exited with code 0]
[Thread 8120.0x26b8 exited with code 0]
[Thread 8120.0x1094 exited with code 0]
[Thread 8120.0x27cc exited with code 0]
[Thread 8120.0x22c8 exited with code 0]
[Inferior 1 (process 8120) exited normally]
The above also happens on lubuntu.
Similar behavior is observed on windows
Entering exit command
gp_exit_cleanup () is called in main in plot.c on Cygwin and lubuntu.
gp_exit_cleanup () is called in WinMain (wgnuplot) or main (gnuplot) in wimmain.c on windows.
Even exit command, gp_exit() seems not to be used.
Is
*****************************
Normally gnuplot should be exited using gp_exit().
***************************
true at present ?
Tatsuro
In stdfn.c
there stated
/* Calls the cleanup functions registered using gp_atexit().
* Normally gnuplot should be exited using gp_exit(). In some cases, this is not
* possible (notably when returning from main(), where some compilers get
* confused because they expect a return statement at the very end. In that
* case, gp_exit_cleanup() should be called before the return statement.
*/
*****************************
Normally gnuplot should be exited using gp_exit().
***************************
However, quick test by gdb
gdb gnuplot
b gp_exit_cleanup
b gp_exit
b debug_exit_handler
r
At gnuplot prompt
gnuplot> exit
gdb tells that gnuplot does not end by gp_exit but by debug_exit_handler.
by exit command value of exit_handlers
On cygwin
Breakpoint 1, gp_exit_cleanup () at ../../gnuplot/src/stdfn.c:440
440 {
(gdb) n
[New Thread 8120.0x26b8]
447 while (exit_handlers) {
(gdb) n
449 (*handler->function)();
(gdb) n
[New Thread 8120.0x27cc]
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
447 while (exit_handlers) {
(gdb) n
449 (*handler->function)();
(gdb) n
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
451 exit_handlers = handler->next;
(gdb) n
452 free(handler);
(gdb) n
447 while (exit_handlers) {
(gdb) n
454 }
(gdb) n
main (argc=<optimized out>, argv=<optimized out>)
at ../../gnuplot/src/plot.c:694
694 return exit_status;
(gdb) n
695 }
(gdb) n
0x61007acf in cygwin_exit_return () from /usr/bin/cygwin1.dll
(gdb) c
Continuing.
Breakpoint 3, debug_exit_handler () at ../../gnuplot/src/stdfn.c:461
461 if (exit_handlers) {
(gdb) p exit_handlers
$1 = (struct EXIT_HANDLER *) 0x0
(gdb) c
Continuing.
[Thread 8120.0x1708 exited with code 0]
[Thread 8120.0x26b8 exited with code 0]
[Thread 8120.0x1094 exited with code 0]
[Thread 8120.0x27cc exited with code 0]
[Thread 8120.0x22c8 exited with code 0]
[Inferior 1 (process 8120) exited normally]
The above also happens on lubuntu.
Similar behavior is observed on windows
Entering exit command
gp_exit_cleanup () is called in main in plot.c on Cygwin and lubuntu.
gp_exit_cleanup () is called in WinMain (wgnuplot) or main (gnuplot) in wimmain.c on windows.
Even exit command, gp_exit() seems not to be used.
Is
*****************************
Normally gnuplot should be exited using gp_exit().
***************************
true at present ?
Tatsuro