Issue #16459 has been reported by ioquatix (Samuel Williams).

----------------------------------------
Bug #16459: <internal:trace_point>:346: [BUG] Segmentation fault at 0x0000000000000008
https://bugs.ruby-lang.org/issues/16459

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: 2.7.0
* Backport: 2.5: DONTNEED, 2.6: DONTNEED
----------------------------------------
My code coverage gem which makes extensive use of `script_compiled` is causing segfault on 2.7.0 when accessing `event.instruction_sequence`. I didn't notice any issue in older rubies.

```
<internal:trace_point>:346: [BUG] Segmentation fault at 0x0000000000000008
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0042 p:0003 s:0214 e:000213 METHOD <internal:trace_point>:346
c:0041 p:0050 s:0210 e:000207 BLOCK  /home/samuel/.rvm/gems/ruby-2.7.0/gems/covered-0.13.1/lib/covered/source.rb:41 [FINISH]
c:0040 p:---- s:0202 e:000201 CFUNC  :eval
c:0039 p:0026 s:0194 E:000578 BLOCK  /home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable/impl.rb:5 [FINISH]
c:0038 p:---- s:0190 e:000189 CFUNC  :catch
c:0037 p:0004 s:0186 E:0005a8 METHOD /home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable/impl.rb:4
c:0036 p:0105 s:0181 e:000180 METHOD /home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:208
c:0035 p:0022 s:0169 e:000168 METHOD /home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:184
c:0034 p:0018 s:0159 e:000158 BLOCK  /home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:154 [FINISH]
c:0033 p:---- s:0155 e:000154 CFUNC  :each
c:0032 p:0005 s:0151 e:000150 METHOD /home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:152
c:0031 p:0029 s:0145 e:000144 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:82
c:0030 p:0125 s:0139 e:000138 CLASS  /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:99
c:0029 p:0084 s:0136 e:000135 CLASS  /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:46
c:0028 p:0007 s:0133 e:000132 CLASS  /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:25
c:0027 p:0019 s:0130 e:000129 TOP    /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:24 [FINISH]
c:0026 p:---- s:0127 e:000126 CFUNC  :require_relative
c:0025 p:0017 s:0122 e:000121 TOP    /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/socket.rb:24 [FINISH]
c:0024 p:---- s:0119 e:000118 CFUNC  :require_relative
c:0023 p:0011 s:0114 e:000113 TOP    /home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/endpoint.rb:22 [FINISH]
c:0022 p:---- s:0111 e:000110 CFUNC  :require
c:0021 p:0005 s:0106 e:000105 TOP    /home/samuel/Documents/socketry/async-http/lib/async/http/server.rb:23 [FINISH]
c:0020 p:---- s:0103 e:000102 CFUNC  :require
c:0019 p:0005 s:0098 e:000097 TOP    /home/samuel/Documents/socketry/async-http/spec/async/http/body/writable_examples.rb:21 [FINISH]
c:0018 p:---- s:0095 e:000094 CFUNC  :require_relative
c:0017 p:0005 s:0090 e:000089 TOP    /home/samuel/Documents/socketry/async-http/spec/async/http/body/slowloris_spec.rb:21 [FINISH]
c:0016 p:---- s:0087 e:000086 CFUNC  :load
c:0015 p:0007 s:0082 e:000081 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:2076
c:0014 p:0023 s:0073 e:000072 BLOCK  /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:1583 [FINISH]
c:0013 p:---- s:0068 e:000067 CFUNC  :each
c:0012 p:0018 s:0064 e:000063 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:1581
c:0011 p:0009 s:0060 e:000059 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/covered-0.13.1/lib/covered/rspec.rb:45
c:0010 p:0036 s:0056 e:000055 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:102
c:0009 p:0007 s:0050 e:000049 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:86
c:0008 p:0065 s:0044 e:000043 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:71
c:0007 p:0020 s:0036 e:000035 METHOD /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:45
c:0006 p:0025 s:0031 e:000030 TOP    /home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/exe/rspec:4 [FINISH]
c:0005 p:---- s:0028 e:000027 CFUNC  :load
c:0004 p:0112 s:0023 E:001210 EVAL   /home/samuel/.rvm/gems/ruby-2.7.0/bin/rspec:23 [FINISH]
c:0003 p:---- s:0018 e:000017 CFUNC  :eval
c:0002 p:0189 s:0011 E:000768 EVAL   /home/samuel/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24 [FINISH]
c:0001 p:0000 s:0003 E:000790 (none) [FINISH]

-- Ruby level backtrace information ----------------------------------------
/home/samuel/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `<main>'
/home/samuel/.rvm/gems/ruby-2.7.0/bin/ruby_executable_hooks:24:in `eval'
/home/samuel/.rvm/gems/ruby-2.7.0/bin/rspec:23:in `<main>'
/home/samuel/.rvm/gems/ruby-2.7.0/bin/rspec:23:in `load'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/exe/rspec:4:in `<top (required)>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:45:in `invoke'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:71:in `run'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:86:in `run'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/runner.rb:102:in `setup'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/covered-0.13.1/lib/covered/rspec.rb:45:in `load_spec_files'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:1581:in `load_spec_files'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:1581:in `each'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:1583:in `block in load_spec_files'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:2076:in `load_file_handling_errors'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/rspec-core-3.9.0/lib/rspec/core/configuration.rb:2076:in `load'
/home/samuel/Documents/socketry/async-http/spec/async/http/body/slowloris_spec.rb:21:in `<top (required)>'
/home/samuel/Documents/socketry/async-http/spec/async/http/body/slowloris_spec.rb:21:in `require_relative'
/home/samuel/Documents/socketry/async-http/spec/async/http/body/writable_examples.rb:21:in `<top (required)>'
/home/samuel/Documents/socketry/async-http/spec/async/http/body/writable_examples.rb:21:in `require'
/home/samuel/Documents/socketry/async-http/lib/async/http/server.rb:23:in `<top (required)>'
/home/samuel/Documents/socketry/async-http/lib/async/http/server.rb:23:in `require'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/endpoint.rb:22:in `<top (required)>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/endpoint.rb:22:in `require_relative'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/socket.rb:24:in `<top (required)>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/socket.rb:24:in `require_relative'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:24:in `<top (required)>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:25:in `<module:Async>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:46:in `<module:IO>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:99:in `<class:Generic>'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/async-io-1.27.1/lib/async/io/generic.rb:82:in `wraps'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:152:in `def_instance_delegators'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:152:in `each'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:154:in `block in def_instance_delegators'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:184:in `def_instance_delegator'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable.rb:208:in `_delegator_method'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable/impl.rb:4:in `_valid_method?'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable/impl.rb:4:in `catch'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable/impl.rb:5:in `block in _valid_method?'
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/ruby/2.7.0/forwardable/impl.rb:5:in `eval'
/home/samuel/.rvm/gems/ruby-2.7.0/gems/covered-0.13.1/lib/covered/source.rb:41:in `block in initialize'
<internal:trace_point>:346:in `instruction_sequence'

-- Machine register context ------------------------------------------------
 RIP: 0x00007f5ebba7c410 RBP: 0x00007f5ebb183718 RSP: 0x00007fff84e05468
 RAX: 0x0000000000012007 RBX: 0x00007f5ebb1836e0 RCX: 0x00007f5ebbbfcee0
 RDX: 0x0000000000002007 RDI: 0x0000000000000000 RSI: 0x0000556d3cb9c068
  R8: 0x0000556d3cb9c068  R9: 0x00007f5ebb1836e0 R10: 0x0000000000000000
 R11: 0x0000556d3cb9c068 R12: 0x0000556d3c5461e0 R13: 0x0000556d3b77a610
 R14: 0x0000556d3b8ad490 R15: 0x00007f5ebb1836e0 EFL: 0x0000000000010202

-- C level backtrace information -------------------------------------------
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_vm_bugreport+0x573) [0x7f5ebbbfb4d3] vm_dump.c:755
[0x7f5ebba23557]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(sigsegv+0x49) [0x7f5ebbb5a279] signal.c:946
/usr/lib/libpthread.so.0(__restore_rt+0x0) [0x7f5ebb8bb930]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_iseqw_new+0x0) [0x7f5ebba7c410] iseq.c:1112
[0x7f5ebbbe30f4]
[0x7f5ebbbe727c]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_vm_invoke_proc+0x292) [0x7f5ebbbec5d2] vm.c:1044
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_proc_call_with_block+0x4d) [0x7f5ebbb04a5d] proc.c:1006
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(tp_call_trace+0x48) [0x7f5ebbbfbf58] vm_trace.c:1108
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(exec_hooks_body+0x86) [0x7f5ebbbfc0d6] vm_trace.c:295
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(exec_hooks_protected+0xb3) [0x7f5ebbbfc953] vm_trace.c:342
[0x7f5ebbbfe02a]
[0x7f5ebbbd95f2]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_f_eval+0x13a) [0x7f5ebbbea2aa] vm_eval.c:1633
[0x7f5ebbbd41ec]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(catch_i+0x2eb) [0x7f5ebbbeb4eb] vm.c:1044
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(vm_catch_protect+0xae) [0x7f5ebbbda35e] vm_eval.c:2308
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_catch_obj+0x2c) [0x7f5ebbbda45c] vm_eval.c:2334
[0x7f5ebbbd41ec]
[0x7f5ebbbe169d]
[0x7f5ebbbe727c]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_yield+0x293) [0x7f5ebbbeb853] vm.c:1044
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_ary_each+0x3c) [0x7f5ebb98df2c] array.c:2135
[0x7f5ebbbd41ec]
[0x7f5ebbbe169d]
[0x7f5ebbbe727c]
[0x7f5ebba83bb5]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_require_string+0x23) [0x7f5ebba842d3] load.c:1105
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
[0x7f5ebba83bb5]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_require_string+0x23) [0x7f5ebba842d3] load.c:1105
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
[0x7f5ebba83bb5]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_require_string+0x23) [0x7f5ebba842d3] load.c:1105
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
[0x7f5ebba83bb5]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_require_string+0x23) [0x7f5ebba842d3] load.c:1105
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
[0x7f5ebba83bb5]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_require_string+0x23) [0x7f5ebba842d3] load.c:1105
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
[0x7f5ebba827bb]
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(vm_call_opt_send+0x2ee) [0x7f5ebbbe99de] vm_insnhelper.c:2661
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_yield+0x293) [0x7f5ebbbeb853] vm.c:1044
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_ary_each+0x3c) [0x7f5ebb98df2c] array.c:2135
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe169d]
[0x7f5ebbbe727c]
[0x7f5ebba827bb]
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe727c]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_f_eval+0x175) [0x7f5ebbbea2e5] vm_eval.c:1646
[0x7f5ebbbd41ec]
[0x7f5ebbbe8eab]
[0x7f5ebbbe15e3]
[0x7f5ebbbe7a64]
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(rb_ec_exec_node+0xaa) [0x7f5ebba27f8a] eval.c:277
/home/samuel/.rvm/rubies/ruby-2.7.0/lib/libruby.so.2.7(ruby_run_node+0x4a) [0x7f5ebba2d63a] eval.c:335
/home/samuel/.rvm/rubies/ruby-2.7.0/bin/ruby(main+0x5b) [0x556d3a14f0fb] ./main.c:50
```

I don't know why it's happening yet, but I'll try to work on short reproduction. As a side request, I didn't realise `TracePoint#instruction_sequence` was so expensive (constructing object). Maybe we can add `eval_path` along with `eval_source` to side step this issue entirely.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>