Skip to content

fix: race condition in EnumWrappers#initialize#3121

Merged
dmulloy2 merged 1 commit intodmulloy2:masterfrom
diogotcorreia:fix/race-condition-enumwrapper-initialize
Jul 23, 2024
Merged

fix: race condition in EnumWrappers#initialize#3121
dmulloy2 merged 1 commit intodmulloy2:masterfrom
diogotcorreia:fix/race-condition-enumwrapper-initialize

Conversation

@diogotcorreia
Copy link
Copy Markdown
Contributor

Adds synchronization primitives inside the initialization function to ensure that when the function returns, everything is guaranteed to be initialized.

Fixes #3120


Most of the diff is just indenting the code that was already there. If you prefer, I can make a second function instead to avoid changing so many lines.

I've also opted by this approach instead of just adding synchronized to the method declaration because that would force synchronization well after everything has been initialized, reducing parallelization (and therefore performance).

The new INITIALIZING variable is necessary because certain function calls inside initialize also call initialize themselves, so moving INITIALIZED = true to the end of the method would enter infinite recursion.

Adds synchronization primitives inside the initialization function to
ensure that when the function returns, everything is guaranteed to be
initialized.

Fixes dmulloy2#3120
@dmulloy2 dmulloy2 force-pushed the fix/race-condition-enumwrapper-initialize branch from 529e55f to 6768cf2 Compare July 23, 2024 02:54
@dmulloy2 dmulloy2 enabled auto-merge (squash) July 23, 2024 02:54
@dmulloy2 dmulloy2 disabled auto-merge July 23, 2024 02:56
@dmulloy2 dmulloy2 merged commit 9fc68d4 into dmulloy2:master Jul 23, 2024
@diogotcorreia diogotcorreia deleted the fix/race-condition-enumwrapper-initialize branch July 23, 2024 09:02
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.

Race condition in EnumWrappers#initialize

2 participants