From d4c36f43b0bdf7594bf3ce8652a9250623f41dee Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 15 Jun 2021 14:23:15 +0200 Subject: Protect the access to module path for executable cache The getPylsModulePath() may be called concurrently: PyLSConfigureAssistant::openDocumentWithPython() -> runAsync -> checkPythonLanguageServer() -> getPylsModulePath(), so protect the access to the static cache by mutex. Amends: 54f2ebf91d76d05d0202de5263939fc4ba227fed Change-Id: Ia88a9e680b092bcc7cf62338387775521d497835 Reviewed-by: Christian Stenger --- src/plugins/python/pythonutils.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/python/pythonutils.cpp') diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp index af1c42b5ab..f679fe2b0f 100644 --- a/src/plugins/python/pythonutils.cpp +++ b/src/plugins/python/pythonutils.cpp @@ -98,6 +98,8 @@ static QString pythonName(const FilePath &pythonPath) FilePath getPylsModulePath(CommandLine pylsCommand) { + static QMutex mutex; // protect the access to the cache + QMutexLocker locker(&mutex); static QMap cache; const FilePath &modulePath = cache.value(pylsCommand.executable()); if (!modulePath.isEmpty()) -- cgit v1.2.1