diff options
author | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2022-10-05 12:09:57 +0200 |
---|---|---|
committer | Yorick van Pelt <yorick@yorickvanpelt.nl> | 2022-11-02 13:02:24 +0100 |
commit | 444af855523b00b0959273bab9d7343312817cb3 (patch) | |
tree | 4588f76695cd94959fd228c965eb5aec03290e5b /src/libcmd/repl.cc | |
parent | 0edba4cc1e8887478ec24a4f07b8849036b8d67f (diff) |
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.
Diffstat (limited to 'src/libcmd/repl.cc')
-rw-r--r-- | src/libcmd/repl.cc | 4 |
1 files changed, 4 insertions, 0 deletions
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 |