diff options
| author | Apollon Oikonomopoulos <apoikos@debian.org> | 2018-03-22 12:04:55 +0200 |
|---|---|---|
| committer | Apollon Oikonomopoulos <apoikos@debian.org> | 2018-03-22 12:04:55 +0200 |
| commit | c49e99631589113663b1a3ac691870421965a315 (patch) | |
| tree | ac8127a5a6816f169a6656511bf131a35af2f74a /src/mongo/scripting/mozjs/PosixNSPR.cpp | |
| parent | d982a88efa79f510c03f1c6c8c63360680ebbf88 (diff) | |
New upstream version 3.4.14upstream/3.4.14
Diffstat (limited to 'src/mongo/scripting/mozjs/PosixNSPR.cpp')
| -rw-r--r-- | src/mongo/scripting/mozjs/PosixNSPR.cpp | 13 |
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 (...) { |
