From 8a5d1c45d2636b781c05884c09d1cb584eac25cd Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Mon, 17 Feb 2025 14:38:46 -0800 Subject: [PATCH] daemon: complain much louder about unknown std::exception instances falling out This made debugging https://git.lix.systems/lix-project/lix/issues/681 a pain in the neck. This is partially a fix, in a certain sense, for https://git.lix.systems/lix-project/lix/issues/379, but that one also addresses expected exceptions from the daemon. Another instance of this error generation site being shit recently: https://git.lix.systems/lix-project/lix/issues/638 I don't know how we should improve that particular site but we definitely should complain about uncaught std exceptions with type ids. Change-Id: I68798300448ee9ebae65c6469ba69e3f933b2895 --- lix/libstore/daemon.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lix/libstore/daemon.cc b/lix/libstore/daemon.cc index 05037c921..a89d943a9 100644 --- a/lix/libstore/daemon.cc +++ b/lix/libstore/daemon.cc @@ -15,6 +15,7 @@ #include "lix/libutil/strings.hh" #include "lix/libutil/args.hh" +#include #include namespace nix::daemon { @@ -1100,9 +1101,15 @@ void processConnection( to.flush(); return; } catch (std::exception & e) { - auto ex = Error(e.what()); + auto ex = Error( + "Unexpected exception on the Lix daemon; this is a bug in Lix.\nWe would appreciate a report of the circumstances it happened in at https://git.lix.systems/lix-project/lix.\n%s: %s", + Uncolored(boost::core::demangle(typeid(e).name())), + e.what() + ); tunnelLogger->stopWork(&ex); to.flush(); + // Crash for good measure, so something winds up in system logs and a core dump is generated as well. + std::terminate(); return; } }