diff options
author | Sam Clegg <sbc@chromium.org> | 2018-11-02 12:07:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-02 12:07:45 -0700 |
commit | 33665b6b0c33e79049c832b9a60dcfe07fa54b59 (patch) | |
tree | 86f3c3ae794f5ca3522b0ce78578719a085d2c6b | |
parent | 0ed4d2fabb8dcfcdf4e5ca79480f75db476fec76 (diff) | |
download | binaryen-33665b6b0c33e79049c832b9a60dcfe07fa54b59.tar.gz binaryen-33665b6b0c33e79049c832b9a60dcfe07fa54b59.tar.bz2 binaryen-33665b6b0c33e79049c832b9a60dcfe07fa54b59.zip |
Don't call static desructors when Fatal() errors occur (#1722)
This was causing a deadlock while destroying the thread pool.
-rw-r--r-- | src/support/threads.cpp | 4 | ||||
-rw-r--r-- | src/support/utilities.h | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/support/threads.cpp b/src/support/threads.cpp index c4bb6e513..7ae304c4f 100644 --- a/src/support/threads.cpp +++ b/src/support/threads.cpp @@ -128,7 +128,7 @@ void ThreadPool::initialize(size_t num) { } size_t ThreadPool::getNumCores() { -#if EMSCRIPTEN +#ifdef __EMSCRIPTEN__ return 1; #else size_t num = std::max(1U, std::thread::hardware_concurrency()); @@ -181,7 +181,7 @@ void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) } DEBUG_POOL("main thread waiting\n"); condition.wait(lock, [this]() { return areThreadsReady(); }); - DEBUG_POOL("main thread waiting\n"); + DEBUG_POOL("main thread done waiting\n"); DEBUG_POOL("running = false\n"); running = false; DEBUG_POOL("work() is done\n"); diff --git a/src/support/utilities.h b/src/support/utilities.h index a2fff7f0a..36f18fa4e 100644 --- a/src/support/utilities.h +++ b/src/support/utilities.h @@ -71,7 +71,10 @@ class Fatal { } WASM_NORETURN ~Fatal() { std::cerr << "\n"; - exit(1); + // Use _Exit here to avoid calling static destructors. This avoids deadlocks + // in (for example) the thread worker pool, where workers hold a lock while + // performing their work. + _Exit(1); } }; |