Skip to content
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

graphql-c_parser: Properly register global variables #4641

Merged

Conversation

casperisfine
Copy link
Contributor

Fix: #4640

GraphQL_Language_Nodes_ are global variables and their value is assigned the return value of const_get which contrary to rb_define_class_* isn't pinned.

So they must be registered with rb_global_variable.

On a side note, rb_global_variable must be called before the variable is assigned, not after.

Fix: rmosolgo#4640

`GraphQL_Language_Nodes_` are global variables and their value is
assigned the return value of `const_get` which contrary to `rb_define_class_*`
isn't pinned.

So they must be registered with `rb_global_variable`.

On a side note, `rb_global_variable` must be called before the variable
is assigned, not after.
@rmosolgo rmosolgo added this to the c-parser-1.0.7 milestone Sep 20, 2023
@rmosolgo
Copy link
Owner

Thanks for fixing this! I thought, since GraphQL_Language_Nodes_... were referencing constants that were already known in Ruby-land, that I wouldn't need to register them again with Ruby. NONE is an exception, but I guess I had the calls out of order in that case, anyways. Thanks for the fix!

@rmosolgo rmosolgo merged commit dd0d716 into rmosolgo:master Sep 20, 2023
12 checks passed
@rmosolgo
Copy link
Owner

released in graphql-c_parser 1.0.7

@casperisfine
Copy link
Contributor Author

that I wouldn't need to register them again with Ruby

Yeah, that's the tricky part here. You don't need to register them again to prevent them from being garbage collected because they are referenced elsewhere.

But on our CI we compact the heap with GC.compact, so references that are not properly registered become stale and point to garbage.

peterzhu2118 added a commit to Shopify/yjit-bench that referenced this pull request Nov 28, 2023
The gem has a bug with compaction that was fixed in
rmosolgo/graphql-ruby#4641.
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.

C Parser is crashing with ruby-head debug builds
3 participants