-
Notifications
You must be signed in to change notification settings - Fork 185
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
rb_gc_register_address and rb_global_variable should read the latest VALUE of the pointer #2721
Comments
I'm unsure how we can solve this from a quick look, because the variable could be reassigned (and we have no way to know that currently I think) and the new handle holding it wouldn't be kept alive. It might not need a handle though and then it'd stay alive anyway as a managed global variable, but some globals need to go native, and might be even become more frequently the case when executing some functions natively instead of on Sulong. Maybe we need some help from Sulong to get notified of writes to the variable or so. Or never allow such variables to go native maybe but that sounds restrictive. |
One idea is most (all?) usages of rb_gc_register_address()/rb_global_variable() are done during the call to the That at least would cover the common case of these functions being called in Init_ automatically and with no overhead. An heavy alternative would be to reread all these variables when returning from C back to Ruby, but that would likely be a significant overhead. |
…the latest value (#2721) PullRequest: truffleruby/3506
…value * By storing the variables addresses and reading them at the end of the Init_ function. * Raise an error if those functions are called outside Init_ functions. * Fixes oracle#2721
truffleruby/src/main/c/cext/gc.c
Lines 15 to 20 in 01607d7
truffleruby/src/main/c/cext/gc.c
Lines 61 to 66 in 01607d7
Originally posted by @eregon in #2720 (comment)
The text was updated successfully, but these errors were encountered: