Skip to content

Make circular type forwarder protection thread-safe#978

Open
ItsZil wants to merge 1 commit intojbevain:masterfrom
Unity-Technologies:circular-type-thread-safe
Open

Make circular type forwarder protection thread-safe#978
ItsZil wants to merge 1 commit intojbevain:masterfrom
Unity-Technologies:circular-type-thread-safe

Conversation

@ItsZil
Copy link
Copy Markdown

@ItsZil ItsZil commented Mar 10, 2026

PR #806 added protection against circular type forwarders using an instance-level bool reentrancyGuard variable. This created race conditions when multiple threads resolved the same ExportedType.

This PR replaces the bool with a [ThreadStatic] static int reentrancyDepth counter, allowing forwarding up to const int MaxForwardingDepth = 16 depth, which is thread-safe and supports legitimate forwarding chains.

I added a test (TypeForwarderMultiLevel) that resolves a simple forwarding chain.

@ItsZil ItsZil force-pushed the circular-type-thread-safe branch from 0e13a43 to ee91148 Compare March 12, 2026 12:47
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.

1 participant