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
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-10-24 14:43:55 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-10-24 14:47:39 +0300
commitcde18cf3b349a3a4d3b435fd3f76e5304ee446d6 (patch)
treef461d5316ac2b9ebeac2f2322c3dc141c516273e /intern
parent963aa7e270816c1654ed668ee0dd370e9598f86a (diff)
Cycles: Fix static initialization order fiasco
Initialization order of global stats and node types was not strictly defined and it was possible to have node types initialized first and stats after that. This will zero out memory which was allocated from the statistics causing assert failure when de-initializing node types.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/util/util_guarded_allocator.cpp2
-rw-r--r--intern/cycles/util/util_stats.h3
2 files changed, 4 insertions, 1 deletions
diff --git a/intern/cycles/util/util_guarded_allocator.cpp b/intern/cycles/util/util_guarded_allocator.cpp
index 8de6e254cbf..615ac95f324 100644
--- a/intern/cycles/util/util_guarded_allocator.cpp
+++ b/intern/cycles/util/util_guarded_allocator.cpp
@@ -19,7 +19,7 @@
CCL_NAMESPACE_BEGIN
-static Stats global_stats;
+static Stats global_stats(Stats::static_init);
/* Internal API. */
diff --git a/intern/cycles/util/util_stats.h b/intern/cycles/util/util_stats.h
index ce27067dc5e..b970b017270 100644
--- a/intern/cycles/util/util_stats.h
+++ b/intern/cycles/util/util_stats.h
@@ -23,7 +23,10 @@ CCL_NAMESPACE_BEGIN
class Stats {
public:
+ enum static_init_t { static_init = 0 };
+
Stats() : mem_used(0), mem_peak(0) {}
+ explicit Stats(static_init_t) {}
void mem_alloc(size_t size) {
atomic_add_z(&mem_used, size);