Multiple threads could be calling into DoLoadImage concurrently,
only one should be allowed to create the UtilityFunction.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | ||
---|---|---|
1046–1047 ↗ | (On Diff #146252) | We should put the mutex, or better yet a std::once_flag, in the process as an instance variable. The utility function belongs to each process. |
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | ||
---|---|---|
1046–1047 ↗ | (On Diff #146252) | I don't disagree, but it seemed a little overkill. Would you just put it as a public member? Or add a GetLoadImageUtilityFunctionOnceFlag() accessor? |
source/Plugins/Platform/POSIX/PlatformPOSIX.cpp | ||
---|---|---|
1047 ↗ | (On Diff #146252) | Accessor would be fine. The other reason for putting this in the process is multi-threaded code that attempts to use this after the main thread has exited will crash as the static mutex might destruct itself. |
Comment Actions
I heted the idea of hosting the once_flag in Process but using
it in PlatformPOSIX. I did a bigger refactoring where platforms
pass a factory lambda to the accessor and the thread-safe init
is done in the Process class itself using this lambda.