From 444af855523b00b0959273bab9d7343312817cb3 Mon Sep 17 00:00:00 2001 From: Yorick van Pelt Date: Wed, 5 Oct 2022 12:09:57 +0200 Subject: Temporarily disable the debugger during completion evaluation readline is not re-entrant, so entering the debugger from the completioncallback results in an eventual segfault. The workaround is to temporarily disable the debugger when searching for possible completions. --- src/libcmd/repl.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/libcmd/repl.cc') diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc index df8932087..bb254ff8d 100644 --- a/src/libcmd/repl.cc +++ b/src/libcmd/repl.cc @@ -384,6 +384,10 @@ StringSet NixRepl::completePrefix(const std::string & prefix) i++; } } else { + /* Temporarily disable the debugger, to avoid re-entering readline. */ + auto debug_repl = state->debugRepl; + state->debugRepl = nullptr; + Finally restoreDebug([&]() { state->debugRepl = debug_repl; }); try { /* This is an expression that should evaluate to an attribute set. Evaluate it to get the names of the -- cgit v1.2.3