summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/support/threads.cpp4
-rw-r--r--src/support/utilities.h5
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);
}
};