-
-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Add thread-safety to TypeAdaptor method adaptation #5621
Conversation
I think one main issue is that other accesses to the method body that don't go through this lock won't care and might see invalid state. But @I-Al-Istannen surely can weigh in on this. |
Yea, this is not quite enough. We could add a flag to the adapt method that defines whether we are only interested in the signature 🤔 |
1eb34e2
to
56845a5
Compare
When checking whether a method overrides another, we need to adapt both methods to a common ground. In an early version this required cloning the entire method, including its body, to perform the adaption. PR #4862 fixed this by nulling the body before cloning the method and then restoring it afterwards. This operation is not thread safe, as it may write concurrently and also modifies what other parallel threads might see when traversing the model. This patch now introduces a private override specifying whether we are only interested in the signature. If that is the case, we explicitly construct a new method using the factory instead of cloning the original. Closes: #5619
56845a5
to
ca1bf5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took over this poor PR, so my review should not count much :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good.
@SirYwell feel free to merge |
Thanks all! |
This should fix #5619, but I am not sure if locking on a method parameter is more elegant than calling clone.