From 16305b28e7bd92a6f25610095d626d492020f3ee Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 5 Jun 2022 17:56:31 -0700 Subject: txr: fix --free-all crash due to atexit order. The --free-all feature is broken. It is needed for confirming lack of memory leaks during development. What breaks it is the atexit call to run_load_hooks in eval.c, which occurs after the atexit call to free_all in txr.c which blows everything away. * Makefile (tst/tests/019/load-hook.ok): Let's put --free-all on this test case, because it has to with the load hooks. Make no mistake though: everything crashes with --free-all, not this test case specifically. * txr.c (opt_free_all): New global variable. (free_all): Free resources only if opt_free_all is true. Lose the paranoid called flag. (main): Register free_all with atexit before callilng init. This ensures that it will be called after any atexit handlers registered as part of init, like the one in sysif.c and eval.c. (txr_main): The --free-all option now just sets opt_free_all. * txr.h (opt_free_all): Declared. --- Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 698ee5a0..4ca6058f 100644 --- a/Makefile +++ b/Makefile @@ -440,6 +440,7 @@ tst/tests/016/%: TXR_DBG_OPTS := tst/tests/017/%: TXR_DBG_OPTS := tst/tests/018/%: TXR_DBG_OPTS := tst/tests/019/%: TXR_DBG_OPTS := +tst/tests/019/load-hook.ok: TXR_DBG_OPTS := --free-all tst/tests/014/dgram-stream.ok: | tst/tests/014/socket-basic.ok -- cgit v1.2.3