Skip to content

Don't give a class body a function's call target on sys.settrace - #2111

Merged
slozier merged 2 commits into
IronLanguages:mainfrom
BCSharp:trace-switch
Oct 23, 2026
Merged

slozier merged 2 commits into
IronLanguages:mainfrom
BCSharp:trace-switch

Conversation

@BCSharp

@BCSharp BCSharp commented Oct 22, 2026

Copy link
Copy Markdown
Member

Resolves #2109 (comment)

It was indeed a race condition between the background precompilation thread and the foregound thread. If the background thread wins then the type is correct (but may be for the wrong trace mode, separate issue). If the foreground reaches the target delegate, it is the wrong type for MakeClass. Setting it to null forces recompilation for the new trace mode (if not cached/used before).

@BCSharp
BCSharp marked this pull request as draft October 22, 2026 22:56
@BCSharp

BCSharp commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

Since for classes the Target delegate is being reset to null on trace mode switch (btw, it is never null in case of functions), the read+test+use sequence has to be atomic to be thread-proof.

@BCSharp
BCSharp marked this pull request as ready for review October 23, 2026 23:20

@slozier slozier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Looks good to me!

@slozier
slozier merged commit ccb948f into IronLanguages:main Oct 23, 2026
74 of 77 checks passed
@BCSharp
BCSharp deleted the trace-switch branch October 24, 2026 00:18
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.

2 participants