From 02103846151aa36ae376f13dfd352e08a4271602 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 24 Jan 2026 20:17:39 +0100 Subject: [PATCH] dtoolbase: Fix static destructor ordering issue --- dtool/src/dtoolbase/deletedBufferChain.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dtool/src/dtoolbase/deletedBufferChain.cxx b/dtool/src/dtoolbase/deletedBufferChain.cxx index f4d269608b..13df8a8b71 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.cxx +++ b/dtool/src/dtoolbase/deletedBufferChain.cxx @@ -167,8 +167,9 @@ get_deleted_chain(size_t buffer_size) { static MutexImpl lock; lock.lock(); - static std::set deleted_chains; - DeletedBufferChain *result = (DeletedBufferChain *)&*deleted_chains.insert(DeletedBufferChain(buffer_size)).first; + alignas(std::set) static char storage[sizeof(std::set)]; + static auto *deleted_chains = new (storage) std::set; + DeletedBufferChain *result = (DeletedBufferChain *)&*deleted_chains->insert(DeletedBufferChain(buffer_size)).first; lock.unlock(); return result; }