Skip to content

Use a different method to avoid thread_local on MacOS#1992

Merged
dsnopek merged 1 commit into
godotengine:masterfrom
dsnopek:better-macos-thread-local-hack-maybe
Jun 29, 2026
Merged

Use a different method to avoid thread_local on MacOS#1992
dsnopek merged 1 commit into
godotengine:masterfrom
dsnopek:better-macos-thread-local-hack-maybe

Conversation

@dsnopek

@dsnopek dsnopek commented May 29, 2026

Copy link
Copy Markdown
Collaborator

On macOS, thread_local storage keeps the library from being unloaded, which breaks hot-reload.

So, we've got some messy code that avoids thread_local, but we broke it at some point (per #1990)

This PR takes an alternative solution to the problem, which should be more efficient, and is definitely less messy.

Marking as DRAFT for now, because I still need to actually test it with hot-reload on macOS :-)

Fixes #1990

@dsnopek dsnopek added this to the 10.x milestone May 29, 2026
@dsnopek
dsnopek requested a review from a team as a code owner May 29, 2026 23:12
@dsnopek dsnopek added the bug This has been identified as a bug label May 29, 2026
@dsnopek dsnopek changed the title [DRAFT] Use a different method to avoid thread_local on MacOS Use a different method to avoid thread_local on MacOS May 30, 2026
@dsnopek

dsnopek commented May 30, 2026

Copy link
Copy Markdown
Collaborator Author

I just tested this with hot-reload on MacOS, and it worked! Taking out of DRAFT

@Bromeon

Bromeon commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Note that hot-reloading might again break if the user uses thread_local, either in their own code or through a third-party library. It might be worth documenting this somewhere 🤔

@dsnopek
dsnopek merged commit ba0edfe into godotengine:master Jun 29, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Off-main-thread instantiation crash on macOS hot-reload builds: _create_instance_func skips _constructing_mutex (unguarded write + unbalanced unlock)

3 participants