Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
BUG: binding visibility for class_exec not thread safe? #4962
Provide at least:
I believe you are correct, the visibility here is getting stepped on by multiple threads.
The logic for
This is a very unusual case, however. Because you're sharing a single global block across all threads, those threads also share state like
We can fix this most simply by cloning the block and its binding when we do a
Thanks for the quick response. That was what I was thinking as well. However when I checked out the code, seems a method setupBlock is trying to clone things; even the bindings. The class_exec should execute on the cloned one. I also tried dup diliberately in my code, however it did not work as there might be references to original underlying stuff. As ruby itself has GIL, that might be why it is working as expected. Anyway I think it worths a fix as it is inconsistent behaviour. Thanks…
On Thu, 11 Jan 2018 at 05:55, Charles Oliver Nutter < ***@***.***> wrote: I believe you are correct, the visibility here is getting stepped on by multiple threads. The logic for class_exec forces the block's binding to public visibility, restoring it on the way back out again. If another thread is also evaluating the block, it will see the visibility change. That's what you see here when the second method is defined private. This is a very unusual case, however. Because you're sharing a single global block across all threads, those threads also share state like $~ value. We can fix this most simply by cloning the block and its binding when we do a class_exec but that will prevent sharing anything, and some of the sharing is intentional. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#4962 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAiSM6ZLcMFr79RGqUaAZJSYI3Awxkp8ks5tJQeQgaJpZM4RYsN9> .
added a commit
Jan 10, 2018
I've pushed branch clone_more_block_for_exec with some extra logic to clone the block and the frame associated with it (which is where the visibility is stored). We'll see how it looks in CI.