From 824c86a2445f7a63d36473301289c03c0f980efd Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 27 Aug 2026 18:19:52 +0100 Subject: [PATCH] Leak iconv lock to preserve better shutdown order --- renderdoc/os/posix/linux/linux_stringio.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/renderdoc/os/posix/linux/linux_stringio.cpp b/renderdoc/os/posix/linux/linux_stringio.cpp index cabbb2e42..33630e313 100644 --- a/renderdoc/os/posix/linux/linux_stringio.cpp +++ b/renderdoc/os/posix/linux/linux_stringio.cpp @@ -739,11 +739,15 @@ iconv_t iconvUTF82Wide = (iconv_t)-1; // iconv is not thread safe when sharing an iconv_t descriptor // I don't expect much contention but if it happens we could TryLock // before creating a temporary iconv_t, or hold two iconv_ts, or something. -Threading::CriticalSection iconvLock; +Threading::CriticalSection &iconvLock() +{ + static Threading::CriticalSection *lock = new Threading::CriticalSection; + return *lock; +} void Shutdown() { - SCOPED_LOCK(iconvLock); + SCOPED_LOCK(iconvLock()); if(iconvWide2UTF8 != (iconv_t)-1) iconv_close(iconvWide2UTF8); @@ -766,7 +770,7 @@ rdcstr Wide2UTF8(const rdcwstr &s) size_t ret; { - SCOPED_LOCK(iconvLock); + SCOPED_LOCK(iconvLock()); if(iconvWide2UTF8 == (iconv_t)-1) iconvWide2UTF8 = iconv_open("UTF-8", "WCHAR_T"); @@ -811,7 +815,7 @@ rdcwstr UTF82Wide(const rdcstr &s) size_t ret; { - SCOPED_LOCK(iconvLock); + SCOPED_LOCK(iconvLock()); if(iconvUTF82Wide == (iconv_t)-1) iconvUTF82Wide = iconv_open("WCHAR_T", "UTF-8");