[Lldb-commits] [PATCH] D46733: Add a lock to PlatformPOSIX::DoLoadImage
Frederic Riss via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu May 10 16:08:12 PDT 2018
friss created this revision.
friss added a reviewer: jingham.
Herald added a subscriber: emaste.
Multiple threads could be calling into DoLoadImage concurrently,
only one should be allowed to create the UtilityFunction.
https://reviews.llvm.org/D46733
Files:
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===================================================================
--- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -1036,17 +1036,23 @@
thread_sp->CalculateExecutionContext(exe_ctx);
Status utility_error;
-
- // The UtilityFunction is held in the Process. Platforms don't track the
- // lifespan of the Targets that use them, we can't put this in the Platform.
- UtilityFunction *dlopen_utility_func
- = process->GetLoadImageUtilityFunction(this);
+ UtilityFunction *dlopen_utility_func;
ValueList arguments;
FunctionCaller *do_dlopen_function = nullptr;
- if (!dlopen_utility_func) {
- // Make the UtilityFunction:
- dlopen_utility_func = MakeLoadImageUtilityFunction(exe_ctx, error);
+ // Multiple threads could be calling into DoLoadImage concurrently,
+ // only one should be allowed to create the UtilityFunction.
+ {
+ static std::mutex do_dlopen_mutex;
+ std::lock_guard<std::mutex> lock(do_dlopen_mutex);
+
+ // The UtilityFunction is held in the Process. Platforms don't track the
+ // lifespan of the Targets that use them, we can't put this in the Platform.
+ dlopen_utility_func = process->GetLoadImageUtilityFunction(this);
+ if (!dlopen_utility_func) {
+ // Make the UtilityFunction:
+ dlopen_utility_func = MakeLoadImageUtilityFunction(exe_ctx, error);
+ }
}
// If we couldn't make it, the error will be in error, so we can exit here.
if (!dlopen_utility_func)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46733.146252.patch
Type: text/x-patch
Size: 1573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180510/c247dad8/attachment.bin>
More information about the lldb-commits
mailing list