summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/mozjs/PosixNSPR.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/scripting/mozjs/PosixNSPR.cpp')
-rw-r--r--src/mongo/scripting/mozjs/PosixNSPR.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/mongo/scripting/mozjs/PosixNSPR.cpp b/src/mongo/scripting/mozjs/PosixNSPR.cpp
index ed1a3d5a49d..9054e930443 100644
--- a/src/mongo/scripting/mozjs/PosixNSPR.cpp
+++ b/src/mongo/scripting/mozjs/PosixNSPR.cpp
@@ -24,6 +24,7 @@
#include "mongo/stdx/chrono.h"
#include "mongo/stdx/condition_variable.h"
+#include "mongo/stdx/memory.h"
#include "mongo/stdx/mutex.h"
#include "mongo/stdx/thread.h"
#include "mongo/util/concurrency/thread_name.h"
@@ -98,9 +99,13 @@ PRThread* PR_CreateThread(PRThreadType type,
MOZ_ASSERT(priority == PR_PRIORITY_NORMAL);
try {
- std::unique_ptr<nspr::Thread, void (*)(nspr::Thread*)> t(
- js_new<nspr::Thread>(start, arg, state != PR_UNJOINABLE_THREAD),
- js_delete_nonconst<nspr::Thread>);
+ // We can't use the nspr allocator to allocate this thread, because under asan we
+ // instrument the allocator so that asan can track the pointers correctly. This
+ // instrumentation
+ // requires that pointers be deleted in the same thread that they were allocated in.
+ // The threads created in PR_CreateThread are not always freed in the same thread
+ // that they were created in. So, we use the standard allocator here.
+ auto t = mongo::stdx::make_unique<nspr::Thread>(start, arg, state != PR_UNJOINABLE_THREAD);
t->thread() = mongo::stdx::thread(&nspr::Thread::ThreadRoutine, t.get());
@@ -118,7 +123,7 @@ PRStatus PR_JoinThread(PRThread* thread) {
try {
thread->thread().join();
- js_delete(thread);
+ delete thread;
return PR_SUCCESS;
} catch (...) {