From d1b9c24afcb18f95169f55fd51fbe03a7a27aff3 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 10 Oct 2017 08:04:19 +0800 Subject: [PATCH] Make Server outlive buffer manager Fixes crashes when trying to access the server to get the session on hooks run during destruction of other managers. Fixes #1622 --- src/main.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 2d7f8307..9de42b48 100644 --- a/src/main.cc +++ b/src/main.cc @@ -550,8 +550,10 @@ int run_server(StringView session, StringView server_init, set_signal_handler(SIGTERM, [](int) { terminate = true; }); } - StringRegistry string_registry; EventManager event_manager; + Server server{session.empty() ? to_string(getpid()) : session.str()}; + + StringRegistry string_registry; GlobalScope global_scope; ShellManager shell_manager; CommandManager command_manager; @@ -574,8 +576,6 @@ int run_server(StringView session, StringView server_init, GlobalScope::instance().options().get_local_option("readonly").set(flags & ServerFlags::ReadOnly); - Server server{session.empty() ? to_string(getpid()) : session.str()}; - bool startup_error = false; if (not (flags & ServerFlags::IgnoreKakrc)) try {