Closed sedubois closed 3 years ago
I am seeing the same problem. For me it started on July 25 after I upgraded IntelliJ to Build #IU-192.5728.98, built on July 23, 2019
. Before that I can confirm that the IDE debug feature was working fine. Now it produces a similar seg fault error as what @sedubois reported above.
With the IntelliJ upgrade, the Rubymine debugger installs debase
version 0.3.0.beta3
, as well as ruby-debug-ide-0.8.0.beta3
.
~/Library/Logs/DiagnosticReports/ruby_2019-07-26-152906_skarger-GTFL.crash
:
@sedubois @skarger Could you try the following workaround: in file /Users/sdubois/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/debase-0.3.0.beta3/lib/debase.rb
add if iseq
after two Debugger.handle_iseq(path, iseq)
accurances
@sedubois @skarger https://youtrack.jetbrains.com/issue/RUBY-24642
@ViugiNick when I make that change it avoids the seg fault error, but it doesn't actually pause execution at the breakpoint I set in IntelliJ.
Maybe it doesn't pause because iseq
is (unexpectedly) nil
?
I'm using this modified code:
module Debase
class << self
attr_accessor :handler
alias start_ setup_tracepoints
alias stop remove_tracepoints
# possibly deprecated options
attr_accessor :keep_frame_binding, :tracing
module InstructionSequenceMixin
def load_iseq(path)
iseq = RubyVM::InstructionSequence.compile_file(path)
Debugger.handle_iseq(path, iseq) if iseq
iseq
end
end
module InstructionSequenceMixin2
def load_iseq(path)
iseq = super(path)
do_set_flags(iseq, path)
iseq
end
def do_set_flags(iseq, path)
Debugger.handle_iseq(path, iseq) if iseq
iseq.each_child { |child_iseq| do_set_flags(child_iseq, path) } if iseq.respond_to? :each_child
end
end
...
@skarger Hmm, could you log path for cases when iseq is nil?
@skarger Or you can just share an example, so I can reproduce the problem
@ViugiNick I attempted to reproduce with an example new Rails app but it successfully paused execution there.
I cannot share the code for the real project I have where it fails to pause. However, I added some logging and ran Debug for an example rspec test from that project. It shows that iseq
is never nil
in the load_iseq
method, but is always nil
in the do_set_flags
method.
@skarger Is it nil for the file with a breakpoint?
@ViugiNick yes it is, if I understand you correctly.
In the IDE I have a breakpoint set in a given file, ./spec/my_spec.rb
.
With my logging in debase
, I see
"do_set_flags: path: /full/path/to/spec/my_spec.rb, iseq nil? true
"
But iseq
is always nil
in do_set_flags
in my experiment.
Here's the logging for do_set_flags
. I have a similar line in the outer load_iseq
.
module InstructionSequenceMixin2
def load_iseq(path)
iseq = super(path)
do_set_flags(iseq, path)
iseq
end
def do_set_flags(iseq, path)
$stderr.puts("do_set_flags: path: #{path}, iseq nil? #{iseq.nil?}")
if iseq
Debugger.handle_iseq(path, iseq)
iseq.each_child { |child_iseq| do_set_flags(child_iseq, path) } if iseq.respond_to? :each_child
end
end
end
In case it matters, it looks like the load_iseq
method is never called for paths in my project - it's only called when loading the gems.
@skarger But if do_set_flags is called for /full/path/to/spec/my_spec.rb
then InstructionSequenceMixin2#load_iseq is called for files from you project. Could you please try temporary disable spring (comment it in boot.rb)
@ViugiNick
In our project we actually don't turn on spring in config/boot.rb. It seems like IntelliJ automatically uses spring though. I have commented bin/spring
and config/spring.rb
, and I've disabled it in the IntelliJ RSpec Run Configurations.
When I Debug the test, it now prints out the following command, which says nothing about spring:
/bin/bash -c "env RBENV_VERSION=2.6.3 /Users/skarger/.rbenv/libexec/rbenv exec bundle exec ruby /Users/skarger/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/ruby-debug-ide-0.8.0.beta3/bin/rdebug-ide --key-value --step-over-in-blocks --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 62453 --host 0.0.0.0 --dispatcher-port 62454 -- /Users/skarger/Code/my-rails-project/bin/rspec /Users/skarger/Code/my-rails-project/spec/service_objects/example_spec.rb --require teamcity/spec/runner/formatter/teamcity/formatter --format Spec::Runner::Formatter::TeamcityFormatter --example \"My Test\""
It does not pause though.
When I tried creating a brand new Rails project it did pause successfully. So maybe the problem has something to do with my existing project's code, Rails configuration, or loaded gems (although Debug was working for that project before the new IntelliJ release.)
The not-pausing problem may be unrelated to the seg fault. I found this other issue: https://youtrack.jetbrains.com/issue/RUBY-20684 I have not read all the comments there yet but it sounds like the same problem. We are using bootsnap in the project.
@ViugiNick I confirmed that bootsnap is the reason it does not pause in my project.
If I comment the require 'bootsnap/setup'
line in config/boot.rb
then Debug will successfully pause execution.
Alternatively, I can configure bootsnap
like so:
config/boot.rb
require 'bundler/setup' # Set up gems listed in the Gemfile.
# require 'bootsnap/setup' <- do not use the default from Rails
require 'bootsnap'
env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || ENV['ENV']
development_mode = ['', nil, 'development'].include?(env)
# The part that makes debugging work is compile_cache_iseq: false
Bootsnap.setup(
cache_dir: File.join('tmp', 'cache'),
development_mode: development_mode,
load_path_cache: true,
autoload_paths_cache: true,
disable_trace: false,
compile_cache_iseq: false,
compile_cache_yaml: true,
)
Also with that change, I no longer need the if iseq
guard clause in debase
to prevent the seg fault. Evidently with bootsnap disabled, iseq
is not nil
.
It would be nice if there's a way for debase
or ruby-debug-ide
to work around bootsnap itself. I'd prefer not commit the config/boot.rb
changes above to my project's repository. I'd rather use the default bootsnap/setup
script if possible, and only disable the iseq caching in a situation like this where it breaks the debugger.
This is also a problem for me. I also getting a SegFault with bootsnap. It doesn't happen if I comment out the bootsnap line in my boot.rb
.
Not everyone uses the same (or any) IDE on my project, so just commenting out bootsnap
in the boot.rb
file won't work.
I'm not sure if making the specific changes to the bootsnap setup as @skarger did above would mess up other folks on my project that do not use an IDE.
@skarger @weedySeaDragon @sedubois We are working on fixing the problem with bootsnap, hopefully, it will be fixed in one of the upcoming releases
@skarger @weedySeaDragon @sedubois @amatrian Could you please check it in RubyMine 2019.2.1 RC
@ViugiNick - working! paused in a Controller as well as a Model just fine.
(Edited to post the correct version info)
RubyMine 2019.2.1 RC
Build #RM-192.6262.39, built on August 15, 2019
...
Runtime version: 11.0.3+12-b304.39 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.6
GC: ParNew, ConcurrentMarkSweep
Memory: 725M
Cores: 8
Registry: ide.tooltip.initialDelay=1089, ide.balloon.shadow.size=0
...
RUBYGEMS VERSION: 2.7.7
RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin15]
INSTALLATION DIRECTORY: ...
USER INSTALLATION DIRECTORY: ...
...
RUBYGEMS PLATFORMS:
ruby
x86_64-darwin-15
GEM PATHS:
/Users/ ... /.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0
...
----------------------
IDE: RubyMine 2019.2.1 RC, build #RM-192.6262.39
OS: Mac OS X 10.13.6[x86_64]
Java: 11.0.3+12-b304.39
RubyMine SDK Environment:
Sdk: rbenv: 2.5.1
Sdk Version: ver.2.5.1p57 ( revision 63029) p57
Ruby Interpreter: /Users/ ... /.rbenv/versions/2.5.1/bin/ruby
RVM Sdk: Rbenv sdk, gemset nullSdk Language Level: 2.5
Not sure if the exact issue, but I've created a sample app that will segfault in String#gsub on startup:
https://github.com/bisrael/debase_crash_app
/bin/zsh -c "bash -c 'env RBENV_VERSION=2.4.7 /usr/local/Cellar/rbenv/1.0.0/libexec/rbenv exec ruby gems/ruby-debug-ide-0.8.0.beta6/bin/rdebug-ide --key-value --step-over-in-blocks --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 55979 --host 0.0.0.0 --dispatcher-port 55980 -- debase_crash_app/bin/rails s'"
Fast Debugger (ruby-debug-ide 0.8.0.beta6, debase 0.3.0.beta7, file filtering is supported, block breakpoints supported, smart steps supported, obtaining return values supported) listens on 0.0.0.0:55979
gems/addressable-2.7.0/lib/addressable/uri.rb:565: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.4.7p357 (2019-08-28 revision 67796) [x86_64-darwin18]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0028 p:---- s:0154 e:000153 CFUNC :gsub
c:0027 p:0316 s:0149 e:000149 (none)
c:0026 p:0362 s:0142 e:000141 METHOD gems/addressable-2.7.0/lib/addressable/uri.rb:565
c:0025 p:0111 s:0132 e:000131 METHOD gems/addressable-2.7.0/lib/addressable/uri.rb:879
c:0024 p:0010 s:0128 e:000127 METHOD gems/addressable-2.7.0/lib/addressable/uri.rb:2160
c:0023 p:0147 s:0124 e:000123 BLOCK gems/webmock-3.3.0/lib/webmock/util/uri.rb:20 [FINISH]
c:0022 p:0079 s:0117 e:000116 METHOD gems/webmock-3.3.0/lib/webmock/util/uri.rb:33
c:0021 p:0059 s:0112 e:000111 METHOD gems/webmock-3.3.0/lib/webmock/request_pattern.rb:114 [FINISH]
c:0020 p:---- s:0107 e:000106 CFUNC :new
c:0019 p:0096 s:0102 e:000101 METHOD gems/webmock-3.3.0/lib/webmock/request_pattern.rb:84
c:0018 p:0035 s:0097 e:000096 METHOD gems/webmock-3.3.0/lib/webmock/request_pattern.rb:19 [FINISH]
c:0017 p:---- s:0090 e:000089 CFUNC :new
c:0016 p:0020 s:0084 e:000083 METHOD gems/webmock-3.3.0/lib/webmock/request_stub.rb:7 [FINISH]
c:0015 p:---- s:0078 e:000077 CFUNC :new
c:0014 p:0040 s:0072 e:000070 METHOD gems/webmock-3.3.0/lib/webmock/api.rb:7
c:0013 p:0164 s:0065 E:000ab0 TOP debase_crash_app/config/application.rb:21 [FINISH]
c:0012 p:---- s:0062 e:000061 CFUNC :require
c:0011 p:0017 s:0057 E:000da8 BLOCK gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:78 [FINISH]
c:0010 p:---- s:0053 e:000052 CFUNC :tap
c:0009 p:0044 s:0049 E:000e60 METHOD gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:75
c:0008 p:0042 s:0045 E:001448 METHOD gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:39
c:0007 p:0149 s:0040 E:001770 TOP gems/railties-4.2.11.1/lib/rails/commands.rb:17 [FINISH]
c:0006 p:---- s:0035 e:000034 CFUNC :require
c:0005 p:0043 s:0030 E:0026f0 TOP debase_crash_app/bin/rails:4 [FINISH]
c:0004 p:---- s:0027 e:000026 CFUNC :debug_load
c:0003 p:0052 s:0020 E:001fc8 METHOD gems/ruby-debug-ide-0.8.0.beta6/lib/ruby-debug-ide.rb:100
c:0002 p:0991 s:0013 E:000e28 EVAL gems/ruby-debug-ide-0.8.0.beta6/bin/rdebug-ide:192 [FINISH]
c:0001 p:0000 s:0003 E:0006f0 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
gems/ruby-debug-ide-0.8.0.beta6/bin/rdebug-ide:192:in `<main>'
gems/ruby-debug-ide-0.8.0.beta6/lib/ruby-debug-ide.rb:100:in `debug_program'
gems/ruby-debug-ide-0.8.0.beta6/lib/ruby-debug-ide.rb:100:in `debug_load'
debase_crash_app/bin/rails:4:in `<top (required)>'
debase_crash_app/bin/rails:4:in `require'
gems/railties-4.2.11.1/lib/rails/commands.rb:17:in `<top (required)>'
gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:75:in `server'
gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
gems/railties-4.2.11.1/lib/rails/commands/commands_tasks.rb:78:in `require'
debase_crash_app/config/application.rb:21:in `<top (required)>'
gems/webmock-3.3.0/lib/webmock/api.rb:7:in `stub_request'
gems/webmock-3.3.0/lib/webmock/api.rb:7:in `new'
gems/webmock-3.3.0/lib/webmock/request_stub.rb:7:in `initialize'
gems/webmock-3.3.0/lib/webmock/request_stub.rb:7:in `new'
gems/webmock-3.3.0/lib/webmock/request_pattern.rb:19:in `initialize'
gems/webmock-3.3.0/lib/webmock/request_pattern.rb:84:in `create_uri_pattern'
gems/webmock-3.3.0/lib/webmock/request_pattern.rb:84:in `new'
gems/webmock-3.3.0/lib/webmock/request_pattern.rb:114:in `initialize'
gems/webmock-3.3.0/lib/webmock/util/uri.rb:33:in `normalize_uri'
gems/webmock-3.3.0/lib/webmock/util/uri.rb:20:in `block in <class:URI>'
gems/addressable-2.7.0/lib/addressable/uri.rb:2160:in `normalize'
gems/addressable-2.7.0/lib/addressable/uri.rb:879:in `normalized_scheme'
gems/addressable-2.7.0/lib/addressable/uri.rb:565:in `normalize_component'
gems/addressable-2.7.0/lib/addressable/uri.rb:410:in `encode_component'
gems/addressable-2.7.0/lib/addressable/uri.rb:410:in `gsub'
-- Machine register context ------------------------------------------------
rax: 0x00007fc66a500000 rbx: 0x00007fc670b83ab0 rcx: 0x0000000000000000
rdx: 0x0000000107b31000 rdi: 0x00007fc670b835d8 rsi: 0x0000000000000005
rbp: 0x00007ffee8533630 rsp: 0x00007ffee8533630 r8: 0x00000000ffffffff
r9: 0x000000010784c0c0 r10: 0x0000000107b30af0 r11: 0x00007fc66a500000
r12: 0x00007fc670b835e8 r13: 0x00007fc670b835d8 r14: 0x00007fc671244f20
r15: 0x0000000000000000 rip: 0x000000010789dce8 rfl: 0x0000000000010246
-- C level backtrace information -------------------------------------------
0 ruby 0x00000001078b1258 rb_vm_bugreport + 136
1 ruby 0x000000010773afe3 rb_bug_context + 467
2 ruby 0x00000001078263a8 sigsegv + 72
3 libsystem_platform.dylib 0x00007fff66bb1b5d _sigtramp + 29
4 ruby 0x000000010789dce8 rb_backref_get + 72
5 ruby 0x00000001077ef3e3 rb_reg_search0 + 371
6 ruby 0x0000000107853289 str_gsub + 249
7 ruby 0x00000001078a47e3 vm_call_cfunc + 275
8 ruby 0x000000010788d270 vm_exec_core + 10096
9 ruby 0x000000010789f010 vm_exec + 128
10 ruby 0x000000010789d9f6 vm_invoke_proc + 262
11 ruby 0x00000001078ab82b vm_call0_body + 1691
12 ruby 0x00000001078ac1ca rb_call0 + 202
13 ruby 0x0000000107899dc9 rb_funcall + 249
14 ruby 0x0000000107762ebb rb_hash_aref + 59
15 ruby 0x00000001078929f9 vm_exec_core + 32505
16 ruby 0x000000010789f010 vm_exec + 128
17 ruby 0x00000001078ac1ca rb_call0 + 202
18 ruby 0x00000001077a84c9 rb_class_new_instance + 41
19 ruby 0x00000001078a47e3 vm_call_cfunc + 275
20 ruby 0x000000010788db01 vm_exec_core + 12289
21 ruby 0x000000010789f010 vm_exec + 128
22 ruby 0x00000001078ac1ca rb_call0 + 202
23 ruby 0x00000001077a84c9 rb_class_new_instance + 41
24 ruby 0x00000001078a47e3 vm_call_cfunc + 275
25 ruby 0x000000010788db01 vm_exec_core + 12289
26 ruby 0x000000010789f010 vm_exec + 128
27 ruby 0x00000001078ac1ca rb_call0 + 202
28 ruby 0x00000001077a84c9 rb_class_new_instance + 41
29 ruby 0x00000001078a47e3 vm_call_cfunc + 275
30 ruby 0x000000010788db01 vm_exec_core + 12289
31 ruby 0x000000010789f010 vm_exec + 128
32 ruby 0x00000001077888c3 rb_load_internal0 + 291
33 ruby 0x0000000107789126 rb_require_internal + 1702
34 ruby 0x0000000107788948 rb_f_require + 24
35 ruby 0x00000001078a47e3 vm_call_cfunc + 275
36 ruby 0x000000010788db01 vm_exec_core + 12289
37 ruby 0x000000010789f010 vm_exec + 128
38 ruby 0x00000001078ac514 invoke_block_from_c_splattable + 500
39 ruby 0x000000010789a30e rb_yield + 158
40 ruby 0x00000001077a802e rb_obj_tap + 14
41 ruby 0x00000001078a47e3 vm_call_cfunc + 275
42 ruby 0x000000010788d270 vm_exec_core + 10096
43 ruby 0x000000010789f010 vm_exec + 128
44 ruby 0x00000001077888c3 rb_load_internal0 + 291
45 ruby 0x0000000107789126 rb_require_internal + 1702
46 ruby 0x0000000107788948 rb_f_require + 24
47 ruby 0x00000001078a47e3 vm_call_cfunc + 275
48 ruby 0x000000010788db01 vm_exec_core + 12289
49 ruby 0x000000010789f010 vm_exec + 128
50 ruby 0x00000001077888c3 rb_load_internal0 + 291
51 ruby 0x000000010778877b rb_load_protect + 203
52 debase_internals.bundle 0x0000000107c00846 zf9f48b911c + 230
53 ruby 0x00000001078a47e3 vm_call_cfunc + 275
54 ruby 0x000000010788db01 vm_exec_core + 12289
55 ruby 0x000000010789f010 vm_exec + 128
56 ruby 0x00000001077441ba ruby_exec_internal + 138
57 ruby 0x00000001077440d8 ruby_run_node + 56
58 ruby 0x00000001076c7b8f main + 79
I can set a breakpoint at the last file gems/addressable-2.7.0/lib/addressable/uri.rb:565
, and the debugger will stop, but then if i try to step into self.encode_component
there, the segfault happens.
@bisrael Could you please update RubyMine. This problem is fixed in a later versions of debase gem
I think I have the latest version:
RubyMine 2019.2.2 Build #RM-192.6603.29, built on September 6, 2019 Licensed to Blake Israel Subscription is active until May 15, 2020 Runtime version: 11.0.3+12-b304.56 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o macOS 10.14.5 GC: ParNew, ConcurrentMarkSweep Memory: 1981M Cores: 8 Registry: debugger.watches.in.variables=false Non-Bundled Plugins: Railways, mobi.hsz.idea.gitignore, net.seesharpsoft.intellij.plugins.csv, org.jetbrains.plugins.ruby-chef, BashSupport, NodeJS, com.dmarcotte.handlebars, com.github.masahirosuzuka.PhoneGapIntelliJPlugin, com.jetbrains.lang.ejs, org.jetbrains.plugins.vue, org.toml.lang, org.rust.lang, ru.adelf.idea.dotenv, AngularJS, zielu.gittoolbox
@bisrael Could you please try this one: https://twitter.com/rubymine/status/1172121556673318912?s=19 Or this one: https://twitter.com/rubymine/status/1172526396880621568?s=19
@ViugiNick - thank you, the EAP is working correctly. I'll leave that repo be if you need something to test against.
This issue is about JetBrains version of the debugger and should be reported at https://youtrack.jetbrains.com/issues/RUBY
As prompted by the command line, I am making a bug report. Not sure if this is the right place to do so! This happened when trying to run an rspec test from within IntelliJ. The debase gem isn't in my Gemfile but somehow loaded by IntelliJ IDEA when debugging.
Console log:
~/Library/Logs/DiagnosticReports/ruby_2019-07-27-092609_sdubois-macbook.crash
: