Skip to content

Commit 18c3f72

Browse files
krzysdzDHowett
authored andcommitted
PowerShell menu completion parser thread-safety fix (#17221)
Fix Terminal crashing when experimental PowerShell menu completion is very quickly invoked multiple times. `Command::ParsePowerShellMenuComplete` can be called from multiple threads, but it uses a `static` `Json::CharReader`, which cannot safely parse data from multiple threads at the same time. Removing `static` fixes the problem, since every function call gets its own `reader`. Validation: Pressed Ctrl+Space quickly a few times with hardcoded huge JSON as the completion payload. Also shown at the end of the second video in #17220. Closes #17220 (cherry picked from commit 44516ad) Service-Card-Id: 92524217 Service-Version: 1.21
1 parent 4d1b543 commit 18c3f72

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cascadia/TerminalSettingsModel/Command.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
690690
auto data = winrt::to_string(json);
691691

692692
std::string errs;
693-
static std::unique_ptr<Json::CharReader> reader{ Json::CharReaderBuilder{}.newCharReader() };
693+
std::unique_ptr<Json::CharReader> reader{ Json::CharReaderBuilder{}.newCharReader() };
694694
Json::Value root;
695695
if (!reader->parse(data.data(), data.data() + data.size(), &root, &errs))
696696
{

0 commit comments

Comments
 (0)