Skip to content

Fix MSVC mutex initialization with older host runtimes - #2354

Merged
doug-walker merged 2 commits into
AcademySoftwareFoundation:mainfrom
zachlewis:codex/msvc-mutex-compat
Sep 29, 2026
Merged

doug-walker merged 2 commits into
AcademySoftwareFoundation:mainfrom
zachlewis:codex/msvc-mutex-compat

Conversation

@zachlewis

@zachlewis zachlewis commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

OCIO built with recent MSVC toolchains may crash when a host application supplies an older MSVC runtime. The newer constexpr mutex constructor skips the runtime initialization that older runtimes expect before locking. This is suspected to cause the OCIO initialization crash reported in OIIO #5493 and discussed on OIIO #5504.

Define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR in OCIO's shared MSVC compiler settings, following OIIO #4914, which addressed OIIO #4641. This restores runtime mutex initialization throughout the build, including the internal Mutex wrapper and direct std::mutex uses.

Validation:

  • CMake checks confirm the definition is enabled for MSVC and absent for Clang.
  • AppleClang Release build of the library and CPU/utility tests passed.
  • All four CTest targets passed: utility tests and CPU tests with default, no-acceleration, and SSE2 settings. The initial sandboxed run could not discover system monitors; rerunning outside the sandbox passed.
  • git diff --check passed.

The Windows/Nuke reproduction and compatibility with an older MSVC runtime have not been tested locally.

--
Assisted-by: OpenAI Codex (GPT-6 Sol)

Disable constexpr mutex construction for MSVC builds, following OIIO's workaround for crashes with older runtimes bundled by host applications.

Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>

@cozdas cozdas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@carolalynn

Copy link
Copy Markdown
Collaborator

This is great please just disclose ai tool use with “assisted by: tool / model” in the pr body if you used one :)

@zachlewis

Copy link
Copy Markdown
Collaborator Author

Oh lordy, I didn't realize I hadn't done that. Shame on me!

@doug-walker
doug-walker merged commit e7b7461 into AcademySoftwareFoundation:main Sep 29, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants