Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-14 16:37:57 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-14 19:21:55 +0300
commitfb6f1aa12f945c6a17ca96f402dec2f6bce81463 (patch)
tree1d44cd37b6a76424d772914cd515d8af88d87d3b /intern/cycles/util/util_thread.cpp
parent93d11edd7e43b6aeb58f3ca6ca9dc92742794a00 (diff)
Fix Cycles Embree crash on macOS, due to too small thread stack size.
Diffstat (limited to 'intern/cycles/util/util_thread.cpp')
-rw-r--r--intern/cycles/util/util_thread.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/intern/cycles/util/util_thread.cpp b/intern/cycles/util/util_thread.cpp
index 4d30e3f564f..f3c6077f6b7 100644
--- a/intern/cycles/util/util_thread.cpp
+++ b/intern/cycles/util/util_thread.cpp
@@ -26,7 +26,17 @@ thread::thread(function<void()> run_cb, int node)
joined_(false),
node_(node)
{
- thread_ = std::thread(&thread::run, this);
+#ifdef __APPLE__
+ /* Set the stack size to 2MB to match Linux. The default 512KB on macOS is
+ * too small for Embree, and consistent stack size also makes things more
+ * predictable in general. */
+ pthread_attr_t attribute;
+ pthread_attr_init(&attribute);
+ pthread_attr_setstacksize(&attribute, 1024*1024*2);
+ pthread_create(&pthread_id, &attribute, run, (void*)this);
+#else
+ std_thread = std::thread(&thread::run, this);
+#endif
}
thread::~thread()
@@ -49,13 +59,17 @@ void *thread::run(void *arg)
bool thread::join()
{
joined_ = true;
+#ifdef __APPLE__
+ return pthread_join(pthread_id, NULL) == 0;
+#else
try {
- thread_.join();
+ std_thread.join();
return true;
}
catch (const std::system_error&) {
return false;
}
+#endif
}
CCL_NAMESPACE_END