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

C Parser is crashing with ruby-head debug builds #4640

Closed
casperisfine opened this issue Sep 19, 2023 · 8 comments · Fixed by #4641
Closed

C Parser is crashing with ruby-head debug builds #4640

casperisfine opened this issue Sep 19, 2023 · 8 comments · Fixed by #4641

Comments

@casperisfine
Copy link
Contributor

Describe the bug

We run our application test suite against Ruby nightly builds and recently we started seeing a crash on Ruby-head debug builds (built with RUBY_DEBUG=1)

/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/c_parser.rb:96: [BUG] Segmentation fault at 0x00007f1bd084ea18
ruby 3.3.0dev (2023-09-19T14:05:51Z shopify 5c5391f444) +YJIT [x86_64-linux]

-- Ruby level backtrace information ----------------------------------------
....
/bundle/ruby/3.3.0+0/gems/graphql-2.0.26/lib/graphql/query.rb:80:in `selected_operation_name'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-2.0.26/lib/graphql/query.rb:245:in `selected_operation'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-2.0.26/lib/graphql/query.rb:467:in `with_prepared_ast'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-2.0.26/lib/graphql/query.rb:407:in `prepare_ast'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-2.0.26/lib/graphql.rb:46:in `parse'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/c_parser.rb:11:in `parse'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/c_parser.rb:95:in `result'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-shopify-0.9.0/lib/graphql/shopify/trace.rb:21:in `parse'
...
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/c_parser.rb:96:in `block in result'
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/c_parser.rb:96:in `c_parse'

-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 6

-- Machine register context ------------------------------------------------
 RIP: 0x000055bf456cf438 RBP: 0x00007f1bd084ea10 RSP: 0x00007ffc475948c0
 RAX: 0x0000000000000000 RBX: 0x00007f1bcdd6c6e0 RCX: 0x0000000000000004
 RDX: 0x0000000000091f11 RDI: 0x00007f1bd084ea10 RSI: 0x0000000000000000
  R8: 0x0000000000000000  R9: 0x0000000000000000 R10: 0x0000000000000000
 R11: 0x00007f1a84c43c20 R12: 0x0000000000000004 R13: 0x00007f1bdd684050
 R14: 0x0000000000091f11 R15: 0x00007f1a84c43c20 EFL: 0x0000000000010202

-- C level backtrace information -------------------------------------------
/usr/local/ruby/bin/ruby(rb_print_backtrace+0x14) [0x55bf456f781a] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_dump.c:772
/usr/local/ruby/bin/ruby(rb_vm_bugreport) /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_dump.c:1088
/usr/local/ruby/bin/ruby(rb_bug_for_fatal_signal+0xee) [0x55bf4587c9ee] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/error.c:819
/usr/local/ruby/bin/ruby(sigsegv+0x4d) [0x55bf4564cb0d] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/signal.c:920
/lib/x86_64-linux-gnu/libc.so.6(0x7f1bddd33520) [0x7f1bddd33520]
/usr/local/ruby/bin/ruby(RBASIC_CLASS+0x0) [0x55bf456cf438] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_callinfo.h:599
/usr/local/ruby/bin/ruby(gccct_method_search) /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_eval.c:471
/usr/local/ruby/bin/ruby(rb_funcallv_scope+0x23) [0x55bf456e3230] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_eval.c:1059
/usr/local/ruby/bin/ruby(rb_funcallv) /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_eval.c:1080
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/graphql_c_parser_ext.so(yyparse+0x1f68) [0x7f1bcdd656a8] graphql-c_parser/ext/graphql_c_parser_ext/parser.y:342
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/graphql_c_parser_ext.so(yyparse) (null):0
/tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/lib/graphql/graphql_c_parser_ext.so(GraphQL_CParser_Parser_c_parse+0x4f) [0x7f1bcdd6067f] /tmp/bundle/ruby/3.3.0+0/gems/graphql-c_parser-1.0.5/ext/graphql_c_parser_ext/graphql_c_parser_ext.c:8
/usr/local/ruby/bin/ruby(vm_call_cfunc_with_frame_+0x10b) [0x55bf456d4d5b] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_insnhelper.c:3475
/usr/local/ruby/bin/ruby(vm_sendish+0x16a) [0x55bf456cda4a] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm_insnhelper.c:5553
/usr/local/ruby/bin/ruby(vm_exec_core+0xa5) [0x55bf456e7425] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/insns.def:835
/usr/local/ruby/bin/ruby(rb_vm_exec+0x1d3) [0x55bf456d9183] /tmp/ruby-build/ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7/vm.c:2401
[0x55bf4ac52127]

Versions

  • graphql-c_parser-1.0.5
  • ruby-3.3.0-5c5391f444624bcee6a258bcc7b4777c7c295ae7 (with RUBY_DEBUG=1, without seem fine)
  • graphql-2.0.26

Steps to reproduce

I haven't had to time to work out a reduced reproduction script yet, I'm mostly giving advance notice in case the bug seem obvious to the author.

Expected behavior

No crash.

Actual behavior

Crash.

@casperisfine
Copy link
Contributor Author

I struggled a bit to run the project test suite locally with the C Parser, but after figuring it out it revealed a bunch of very suspicious errors:

Error:
GraphQL::Dataloader::AsyncDataloader::With the toy scheduler from Ruby's tests#test_0003_works with GraphQL:
NotImplementedError: method `hash' called on hidden T_FILE object (0x0000000119cd5ca0 flags=0xb)
    src/graphql-ruby/spec/support/dummy_scheduler.rb:159:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in `sleep'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `public_send'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `block (2 levels) in resolve'
    src/graphql-ruby/lib/graphql/schema/field.rb:832:in `with_extensions'
    src/graphql-ruby/lib/graphql/schema/field.rb:669:in `block in resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:955:in `minimal_after_lazy'
    src/graphql-ruby/lib/graphql/query.rb:366:in `after_lazy'
    src/graphql-ruby/lib/graphql/schema/field.rb:667:in `resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:541:in `block (2 levels) in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/tracing/trace.rb:51:in `execute_field'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:540:in `block in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:894:in `call_method_on_directives'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:537:in `evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:513:in `block in evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:1013:in `after_lazy'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:461:in `evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:455:in `block in evaluate_selection'
    src/graphql-ruby/lib/graphql/execution/interpreter/arguments_cache.rb:51:in `block in dataload_for'
    src/graphql-ruby/lib/graphql/schema/member/has_arguments.rb:300:in `block (3 levels) in coerce_arguments'
    src/graphql-ruby/lib/graphql/dataloader.rb:190:in `block in run'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::With the toy scheduler from Ruby's tests#test_0001_runs IO in parallel by default:
NotImplementedError: method `hash' called on hidden T_FILE object (0x0000000119cd1680 flags=0xb)
    src/graphql-ruby/spec/support/dummy_scheduler.rb:159:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:101:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:101:in `block (3 levels) in included'
    src/graphql-ruby/lib/graphql/dataloader.rb:190:in `block in run'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::With the toy scheduler from Ruby's tests#test_0005_runs dataloaders in parallel across branches:
NotImplementedError: method `hash' called on hidden T_FILE object (0x0000000119c75ee0 flags=0xb)
    src/graphql-ruby/spec/support/dummy_scheduler.rb:159:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:23:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:23:in `fetch'
    src/graphql-ruby/lib/graphql/dataloader/source.rb:135:in `run_pending_keys'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `each'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `block in create_source_fiber'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::With the toy scheduler from Ruby's tests#test_0002_works with sources:
NotImplementedError: method `hash' called on hidden T_FILE object (0x0000000119c5e990 flags=0xb)
    src/graphql-ruby/spec/support/dummy_scheduler.rb:159:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:10:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:10:in `fetch'
    src/graphql-ruby/lib/graphql/dataloader/source.rb:135:in `run_pending_keys'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `each'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `block in create_source_fiber'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::With the toy scheduler from Ruby's tests#test_0004_nested fields don't wait for slower higher-level fields:
NotImplementedError: method `hash' called on hidden T_FILE object (0x0000000119c35da0 flags=0xb)
    src/graphql-ruby/spec/support/dummy_scheduler.rb:159:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in `sleep'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `public_send'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `block (2 levels) in resolve'
    src/graphql-ruby/lib/graphql/schema/field.rb:832:in `with_extensions'
    src/graphql-ruby/lib/graphql/schema/field.rb:669:in `block in resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:955:in `minimal_after_lazy'
    src/graphql-ruby/lib/graphql/query.rb:366:in `after_lazy'
    src/graphql-ruby/lib/graphql/schema/field.rb:667:in `resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:541:in `block (2 levels) in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/tracing/trace.rb:51:in `execute_field'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:540:in `block in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:894:in `call_method_on_directives'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:537:in `evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:513:in `block in evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:1013:in `after_lazy'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:461:in `evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:455:in `block in evaluate_selection'
    src/graphql-ruby/lib/graphql/execution/interpreter/arguments_cache.rb:51:in `block in dataload_for'
    src/graphql-ruby/lib/graphql/schema/member/has_arguments.rb:300:in `block (3 levels) in coerce_arguments'
    src/graphql-ruby/lib/graphql/dataloader.rb:190:in `block in run'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::with evt#test_0002_works with sources:
NotImplementedError: method `hash' called on hidden T_FILE object (0x000000011ae1edf0 flags=0xb)
    /Users/byroot/.gem/ruby/3.3.0/gems/evt-0.4.0/lib/evt/backends/bundled.rb:100:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:10:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:10:in `fetch'
    src/graphql-ruby/lib/graphql/dataloader/source.rb:135:in `run_pending_keys'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `each'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `block in create_source_fiber'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::with evt#test_0001_runs IO in parallel by default:
NotImplementedError: method `hash' called on hidden T_FILE object (0x000000011ae1b880 flags=0xb)
    /Users/byroot/.gem/ruby/3.3.0/gems/evt-0.4.0/lib/evt/backends/bundled.rb:100:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:101:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:101:in `block (3 levels) in included'
    src/graphql-ruby/lib/graphql/dataloader.rb:190:in `block in run'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::with evt#test_0003_works with GraphQL:
NotImplementedError: method `hash' called on hidden T_FILE object (0x000000011adfae80 flags=0xb)
    /Users/byroot/.gem/ruby/3.3.0/gems/evt-0.4.0/lib/evt/backends/bundled.rb:100:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in `sleep'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `public_send'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `block (2 levels) in resolve'
    src/graphql-ruby/lib/graphql/schema/field.rb:832:in `with_extensions'
    src/graphql-ruby/lib/graphql/schema/field.rb:669:in `block in resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:955:in `minimal_after_lazy'
    src/graphql-ruby/lib/graphql/query.rb:366:in `after_lazy'
    src/graphql-ruby/lib/graphql/schema/field.rb:667:in `resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:541:in `block (2 levels) in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/tracing/trace.rb:51:in `execute_field'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:540:in `block in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:894:in `call_method_on_directives'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:537:in `evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:513:in `block in evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:1013:in `after_lazy'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:461:in `evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:455:in `block in evaluate_selection'
    src/graphql-ruby/lib/graphql/execution/interpreter/arguments_cache.rb:51:in `block in dataload_for'
    src/graphql-ruby/lib/graphql/schema/member/has_arguments.rb:300:in `block (3 levels) in coerce_arguments'
    src/graphql-ruby/lib/graphql/dataloader.rb:190:in `block in run'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::with evt#test_0005_runs dataloaders in parallel across branches:
NotImplementedError: method `hash' called on hidden T_FILE object (0x000000011ab7dc80 flags=0xb)
    /Users/byroot/.gem/ruby/3.3.0/gems/evt-0.4.0/lib/evt/backends/bundled.rb:100:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:23:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:23:in `fetch'
    src/graphql-ruby/lib/graphql/dataloader/source.rb:135:in `run_pending_keys'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `each'
    src/graphql-ruby/lib/graphql/dataloader.rb:278:in `block in create_source_fiber'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

Error:
GraphQL::Dataloader::AsyncDataloader::with evt#test_0004_nested fields don't wait for slower higher-level fields:
NotImplementedError: method `hash' called on hidden T_FILE object (0x000000011b19ee90 flags=0xb)
    /Users/byroot/.gem/ruby/3.3.0/gems/evt-0.4.0/lib/evt/backends/bundled.rb:100:in `io_wait'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in ``'
    src/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb:69:in `sleep'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `public_send'
    src/graphql-ruby/lib/graphql/schema/field.rb:698:in `block (2 levels) in resolve'
    src/graphql-ruby/lib/graphql/schema/field.rb:832:in `with_extensions'
    src/graphql-ruby/lib/graphql/schema/field.rb:669:in `block in resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:955:in `minimal_after_lazy'
    src/graphql-ruby/lib/graphql/query.rb:366:in `after_lazy'
    src/graphql-ruby/lib/graphql/schema/field.rb:667:in `resolve'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:541:in `block (2 levels) in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/tracing/trace.rb:51:in `execute_field'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:540:in `block in evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:894:in `call_method_on_directives'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:537:in `evaluate_selection_with_resolved_keyword_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:513:in `block in evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:1013:in `after_lazy'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:461:in `evaluate_selection_with_args'
    src/graphql-ruby/lib/graphql/execution/interpreter/runtime.rb:455:in `block in evaluate_selection'
    src/graphql-ruby/lib/graphql/execution/interpreter/arguments_cache.rb:51:in `block in dataload_for'
    src/graphql-ruby/lib/graphql/schema/member/has_arguments.rb:300:in `block (3 levels) in coerce_arguments'
    src/graphql-ruby/lib/graphql/dataloader.rb:190:in `block in run'
    src/graphql-ruby/lib/graphql/dataloader.rb:310:in `block in spawn_fiber'

At a glance this looks like a GC issue, probably an unmarked reference.

@casperisfine
Copy link
Contributor Author

Actually none of the above seem to involve the parser.

@casperisfine
Copy link
Contributor Author

Ok, I believe I found the issue:

(gdb) p *(RBasic *)GraphQL_Language_Nodes_NONE
$15 = {flags = 42949683495, klass = 140002193826816}
(gdb) p *(RBasic *)GraphQL_Language_Nodes_Argument
Cannot access memory at address 0x7f54c1b9e5a0

GraphQL_Language_Nodes_NONE is properly registered with rb_global_variable, but all other GraphQL_Language_Nodes_ aren't.

I'll submit a PR, but I'm having a bit of a trouble building the extension locally because of ragel and Bison requirements.

casperisfine pushed a commit to casperisfine/graphql-ruby that referenced this issue Sep 20, 2023
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.
casperisfine pushed a commit to casperisfine/graphql-ruby that referenced this issue Sep 20, 2023
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.
@casperisfine
Copy link
Contributor Author

Note, the test failures in evt are likely of the same nature:

NotImplementedError: method `hash' called on hidden T_FILE object (0x000000011adfae80 flags=0xb)
    /Users/byroot/.gem/ruby/3.3.0/gems/evt-0.4.0/lib/evt/backends/bundled.rb:100:in `io_wait'

evt clearly fails to mark a reference, and it end up replaced by another object.

@casperisfine
Copy link
Contributor Author

Note, the test failures in evt are likely of the same nature:

Nevermind, the faulty object is the one recieved as argument from graphql so the bug must be in GraphQL.

@casperisfine
Copy link
Contributor Author

Interesting. With allocation tracing on, It appears the Hidden FILE is allocated by:

`sleep #{max_wait}`
E{"address":"0x15d8dbde0", "type":"FILE", "shape_id":0, "slot_size":40, "fd":14, "references":["0x15d8dbde0"], "file":"/Users/byroot/src/github.com/casperisfine/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb", "line":23, "method":"`", "generation":83, "memsize":248}
E{"address":"0x15d8daca0", "type":"FILE", "shape_id":0, "slot_size":40, "fd":16, "references":["0x15d8daca0"], "file":"/Users/byroot/src/github.com/casperisfine/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb", "line":10, "method":"`", "generation":83, "memsize":248}
E{"address":"0x15d8d6860", "type":"FILE", "shape_id":0, "slot_size":40, "fd":18, "references":["0x15d8d6860"], "file":"/Users/byroot/src/github.com/casperisfine/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb", "line":69, "method":"`", "generation":83, "memsize":248}
E{"address":"0x15d8d5b70", "type":"FILE", "shape_id":0, "slot_size":40, "fd":20, "references":["0x15d8d5b70"], "file":"/Users/byroot/src/github.com/casperisfine/graphql-ruby/spec/graphql/dataloader/async_dataloader_spec.rb", "line":101, "method":"`", "generation":83, "memsize":248}

So this might actually be a bug in Ruby, I'll report it to the owner.

@casperisfine
Copy link
Contributor Author

Ok, I git a fix for it ruby/ruby#8485

@rmosolgo
Copy link
Owner

Thanks for sharing all your research on this 👍

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 a pull request may close this issue.

2 participants