Skip to content

Commit 5e78cb7

Browse files
committed
Destroy TCP connections before modules
This fixes a possible double-free during shutdown. The issue was that the `tls_mgm` module was unloaded (free'ing all of its "domains") before the connections were destroyed. This left connections with dangling pointers to the domains, and when the connections are cleaned up, if the reference count is 0, `tls_mgm` can then try to free the domain again, causing a crash. The solution is to defer `destroy_modules()` until after `tcp_destroy()`. It is possible that there are other related bugs that could be solved in the same way (i.e. that `destroy_modules()` should move even further down) but I've tried to be conservative.
1 parent a13e034 commit 5e78cb7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

shutdown.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ void cleanup(int show_status)
5858
#endif
5959

6060
handle_ql_shutdown();
61-
destroy_modules();
6261
udp_destroy();
6362
tcp_destroy();
63+
destroy_modules();
6464
destroy_timer();
6565
if (shm_memlog_size)
6666
shm_mem_disable_dbg();

0 commit comments

Comments
 (0)