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.
This commit is contained in:
Yorick van Pelt 2022-10-05 12:09:57 +02:00
parent 0edba4cc1e
commit 444af85552
No known key found for this signature in database
GPG key ID: A36E70F9DC014A15

View file

@ -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