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

Since ruby 2.7.0, byebug next command doesn't stop in many cases #719

Open
0x2c7 opened this issue Aug 25, 2020 · 3 comments
Open

Since ruby 2.7.0, byebug next command doesn't stop in many cases #719

0x2c7 opened this issue Aug 25, 2020 · 3 comments

Comments

@0x2c7
Copy link

0x2c7 commented Aug 25, 2020

Problem description

Since Ruby 2.7.0, next command doesn't stop in many cases, when calling some standard lib's methods.

Example:

require 'byebug'

def test
  GC.start # Or SecureRandom.uuid, or Base64.encode64, etc.
end
byebug
test
test

When running the above file, and type next, the program doesn't stop at the second method call. Instead, it continues til the end. When adding a tracepoint hook, I found out that in Ruby 2.7.0+ adds some weird events <internal:*>, such as <internal:gc>, <internal:pack>, etc.

  trace = TracePoint.new(:line, :call) do |point|
    puts "#{point.event}: #{point.path}:#{point.lineno}"
  end
  trace.enable
  SecureRandom.uuid
  trace.disable

The above sample code returns:

line: test9.rb:8
call: /home/.rbenv/versions/2.7.0/lib/ruby/2.7.0/securerandom.rb:252
...
line: /home/.rbenv/versions/2.7.0/lib/ruby/2.7.0/securerandom.rb:130
call: <internal:pack>:256 
line: <internal:pack>:257
line: /home/.rbenv/versions/2.7.0/lib/ruby/2.7.0/securerandom.rb:254
line: /home/.rbenv/versions/2.7.0/lib/ruby/2.7.0/securerandom.rb:255
line: /home/.rbenv/versions/2.7.0/lib/ruby/2.7.0/securerandom.rb:256
line: test9.rb:9

Similarly when running the test example with GC#start

line: test9.rb:8
call: <internal:gc>:33
line: <internal:gc>:34
line: test9.rb:9

When running again with methods in the same file that don't trigger <internal*> events, such as SecureRandom.uuid, next command works perfectly. So, I suspect the new <internal:*> event in tracepoint API breaks byebug. I'm debugging deep into C layer, but haven't found anything interesting yet.

@0x2c7
Copy link
Author

0x2c7 commented Sep 4, 2020

Updated: after trying to debug, I found out that TracePoint API doesn't trigger return event after return from <internal:*>. In other cases, when openning a new control frame, there is always a pair of call and return events from Tracepoint. However, in the case of <internal:*>, the return event is missing. It makes Byebug fails to call RETURN_EVENT_SETUP correctly, and leads to dc->calced_stack_size is out-synced with the real stack size. Eventually, byebug fails to reach the next destination, and exits the program.

@0x2c7
Copy link
Author

0x2c7 commented Sep 4, 2020

Update: Ruby trunk already has a fix for this issue. It is fixed in this commit: ruby/ruby@3e02cd5. However, the next ruby release in trunk is now 3.0.0. I'll create a ticket in Ruby issue to ask for a backport instead.

@0x2c7
Copy link
Author

0x2c7 commented Sep 6, 2020

Update:

Let's wait for Ruby 2.7.2 😄

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

No branches or pull requests

1 participant