Skip to content

Commit c7dc41d

Browse files
committed
fix: add workaround for MSVC constexpr mutex constructor in debug builds
1 parent 21ff39a commit c7dc41d

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ if(APPLE)
111111
BUNDLE DESTINATION "Applications"
112112
COMPONENT "Standalone")
113113
elseif(WIN32)
114+
# MSVC 14.44+ introduced a constexpr std::mutex constructor that zero-initializes
115+
# _Thread_id to -1. In debug builds, _Mtx_lock's deadlock detection can misfire
116+
# when JUCE acquires a mutex inside a noexcept function (MessageManager::isThisTheMessageThread),
117+
# causing std::terminate(). This define restores the old _Mtx_init_in_situ path.
118+
target_compile_definitions(element_app PRIVATE
119+
$<$<CONFIG:Debug>:_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR>)
114120
if(ELEMENT_ENABLE_UPDATER)
115121
target_link_libraries(element_app PRIVATE WinSparkle::WinSparkle)
116122
target_sources(element_app PRIVATE src/winsparkle.cc)

‎src/CMakeLists.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,10 @@ if(ELEMENT_ENABLE_VST2)
109109
target_compile_definitions(element PUBLIC JUCE_PLUGINHOST_VST=1)
110110
target_link_libraries(element PUBLIC juce_vst2_sdk)
111111
endif()
112+
113+
# MSVC 14.44+ constexpr mutex constructor workaround (debug only).
114+
# See CMakeLists.txt in the root for explanation.
115+
if(MSVC)
116+
target_compile_definitions(element PRIVATE
117+
$<$<CONFIG:Debug>:_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR>)
118+
endif()

0 commit comments

Comments
 (0)