oj: Segfault in OJ with rails 6.1

I’m having an issue with my application segfaulting when upgrading to rails61. The issue seems to be with OJ. I’m getting this even after updating OJ to latest version

The stack trace is below

Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4/lib/active_record/serialization.rb:21:in `serializable_hash'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.4/lib/active_model/serialization.rb:126:in `serializable_hash'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activerecord-6.1.4/lib/active_record/attribute_methods.rb:265:in `attributes'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.4/lib/active_model/attribute_set.rb:29:in `to_hash'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4/lib/active_support/core_ext/enumerable.rb:81:in `index_with'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4/lib/active_support/core_ext/enumerable.rb:81:in `each'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.4/lib/active_support/core_ext/enumerable.rb:81:in `block in index_with'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.4/lib/active_model/attribute_set.rb:29:in `block in to_hash'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.4/lib/active_model/attribute.rb:43:in `value'
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/activemodel-6.1.4/lib/active_model/attribute.rb:164:in `type_cast'
Sep 21 18:57:03  production.web.1 /app/app/data_types/jsonb_type.rb:11:in `deserialize'
Sep 21 18:57:03  production.web.1 /app/app/data_types/jsonb_type.rb:11:in `load'
Sep 21 18:57:03  production.web.1 -- Machine register context ------------------------------------------------
Sep 21 18:57:03  production.web.1  RIP: 0x00007f3eafc27a2c RBP: 0x00007ffc93a57fb0 RSP: 0x00007ffc93a57f70
Sep 21 18:57:03  production.web.1  RAX: 0x00007ffc93ab21a7 RBX: 0x000055d5905bb150 RCX: 0x000055d59aa46980
Sep 21 18:57:03  production.web.1  RDX: 0x00007ffc93ab21aa RDI: 0x00007ffc93a580ae RSI: 0x00007ffc93a578f0
Sep 21 18:57:03  production.web.1   R8: 0x00007ffc93a580ae  R9: 0x0000000000000073 R10: 0x000000000000003a
Sep 21 18:57:03  production.web.1  R11: 0xfffffffffffa5e1e R12: 0x000055d5905bb150 R13: 0x00007ffc93a58ad0
Sep 21 18:57:03  production.web.1  R14: 0x0000000000000000 R15: 0x0000000000029d9b EFL: 0x0000000000010283
Sep 21 18:57:03  production.web.1 -- C level backtrace information -------------------------------------------
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_vm_bugreport+0x7ce) [0x7f3ebbedb33e] vm_dump.c:755
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_bug_for_fatal_signal+0xe7) [0x7f3ebbcfadb7] error.c:660
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(sigsegv+0x4b) [0x7f3ebbe3f43b] signal.c:946
Sep 21 18:57:03  production.web.1 /lib/x86_64-linux-gnu/libc.so.6(0x7f3ebb87cf20) [0x7f3ebb87cf20]
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(oj_set_error_at+0x20c) [0x7f3eafc27a2c] parse.c:944
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(oj_set_error_at) (null):0
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(resolve_classpath+0x15b) [0x7f3eafc1bfdb] intern.c:211
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(oj_class_intern+0x240) [0x7f3eafc1c570] intern.c:249
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(hash_set_cstr+0x3c5) [0x7f3eafc216a5] object.c:214
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(oj_parse2+0xb6e) [0x7f3eafc2a3de] parse.c:372
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(protect_parse+0x9) [0x7f3eafc2a509] parse.c:959
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_protect+0x144) [0x7f3ebbd059e4] eval.c:1087
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(oj_pi_parse+0x15e) [0x7f3eafc2a67e] parse.c:1068
Sep 21 18:57:03  production.web.1 /app/vendor/bundle/ruby/2.7.0/gems/oj-3.13.7/lib/oj/oj.so(oj_object_parse+0xb6) [0x7f3eafc21926] object.c:728
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_call_cfunc+0x11a) [0x7f3ebbeb79aa] vm_insnhelper.c:2514
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_exec_core+0x156) [0x7f3ebbec3016] vm_insnhelper.c:4023
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_vm_exec+0xab) [0x7f3ebbec93fb] vm.c:1920
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_yield+0x1ae) [0x7f3ebbeca0ee] vm.c:1116
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_ary_each+0x3c) [0x7f3ebbc65a8c] array.c:2135
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_call_cfunc+0x11a) [0x7f3ebbeb79aa] vm_insnhelper.c:2514
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_exec_core+0x20d) [0x7f3ebbec30cd] vm_insnhelper.c:4023
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_vm_exec+0xab) [0x7f3ebbec93fb] vm.c:1920
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_yield+0x1ae) [0x7f3ebbeca0ee] vm.c:1116
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_ary_collect+0x5c) [0x7f3ebbc6b73c] array.c:3065
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_call_cfunc+0x11a) [0x7f3ebbeb79aa] vm_insnhelper.c:2514
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_exec_core+0x20d) [0x7f3ebbec30cd] vm_insnhelper.c:4023
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_vm_exec+0xab) [0x7f3ebbec93fb] vm.c:1920
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_yield_values2+0x26e) [0x7f3ebbecc55e] vm.c:1116
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(each_pair_i_fast+0x3b) [0x7f3ebbd28a6b] hash.c:3062
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(hash_ar_foreach_iter+0xf) [0x7f3ebbd2a9ef] hash.c:1337
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(hash_foreach_call) hash.c:962
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_ensure+0xd4) [0x7f3ebbd05b94] eval.c:1129
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_hash_foreach+0xbf) [0x7f3ebbd30f3f] hash.c:1509
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_hash_each_pair+0x28) [0x7f3ebbd31c38] hash.c:3093
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_call_cfunc+0x11a) [0x7f3ebbeb79aa] vm_insnhelper.c:2514
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_exec_core+0x20d) [0x7f3ebbec30cd] vm_insnhelper.c:4023
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_vm_exec+0xab) [0x7f3ebbec93fb] vm.c:1920
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_ec_vm_ptr+0x0) [0x7f3ebbecce1d] vm.c:1074
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(rb_vm_invoke_bmethod) vm_core.h:1932
Sep 21 18:57:03  production.web.1 /app/vendor/ruby-2.7.3/bin/../lib/libruby.so.2.7(vm_call_bmethod+0xac) [0x7f3ebbed373c] vm_insnhelper.c:2570

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (21 by maintainers)

Most upvoted comments

I’m not sure what Oj can do about Rails class changes. I agree that it is pretty annoying that Rails doesn’t follow semantic versioning by breaking compatibility on a minor release but providing a migration feature is really out of scope for Oj.

Having said that I’d be glad to help put together a migration script outside of the Oj project.