Skip to content

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

@casperisfine

Description

@casperisfine

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions