Skip to content

Comments

Fix bug that error occurs after detaching to Chrome#411

Merged
ko1 merged 1 commit intoruby:masterfrom
ono-max:fix-bug
Dec 7, 2021
Merged

Fix bug that error occurs after detaching to Chrome#411
ko1 merged 1 commit intoruby:masterfrom
ono-max:fix-bug

Conversation

@ono-max
Copy link
Member

@ono-max ono-max commented Nov 25, 2021

@ko1-san pointed out that error occurs after detaching to Chrome.

Reproduce

module Foo
  class Bar
    def self.a
      "hello"
    end
  end
  loop do
    Bar.a
  end
  bar = Bar.new
end

Set the breakpoint at line 7, then close the tab.

Result

#<Thread:0x00007fed9cae4ac0@DEBUGGER__::SESSION@server@/Users/naotto/workspace/debug/lib/debug/session.rb:146 run> terminated with exception (report_on_exception is true):
/Users/naotto/workspace/debug/lib/debug/server_cdp.rb:305:in `readline': undefined method `pop' for nil:NilClass (NoMethodError)
	from /Users/naotto/workspace/debug/lib/debug/session.rb:371:in `wait_command'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:331:in `block in wait_command_loop'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:330:in `loop'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:330:in `wait_command_loop'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:252:in `process_event'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:196:in `session_server_main'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:166:in `block in activate'
["DEBUGGER Exception: /Users/naotto/workspace/debug/lib/debug/thread_client.rb:970",
 #<NoMethodError: undefined method `pop' for nil:NilClass>,
 ["/Users/naotto/workspace/debug/lib/debug/server_cdp.rb:305:in `readline'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:371:in `wait_command'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:331:in `block in wait_command_loop'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:330:in `loop'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:330:in `wait_command_loop'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:252:in `process_event'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:196:in `session_server_main'",
  "/Users/naotto/workspace/debug/lib/debug/session.rb:166:in `block in activate'"]]
/Users/naotto/workspace/debug/lib/debug/server_cdp.rb:305:in `readline': undefined method `pop' for nil:NilClass (NoMethodError)
	from /Users/naotto/workspace/debug/lib/debug/session.rb:371:in `wait_command'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:331:in `block in wait_command_loop'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:330:in `loop'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:330:in `wait_command_loop'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:252:in `process_event'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:196:in `session_server_main'
	from /Users/naotto/workspace/debug/lib/debug/session.rb:166:in `block in activate'

Reason

The reason is that readline is called after thread terminated. This PR fixes it.

@ono-max ono-max force-pushed the fix-bug branch 2 times, most recently from 8b84df6 to d0eb807 Compare November 26, 2021 01:12
@ono-max ono-max marked this pull request as draft December 2, 2021 11:15
@ono-max ono-max marked this pull request as ready for review December 5, 2021 12:11
@ko1 ko1 merged commit 321b12d into ruby:master Dec 7, 2021
@ono-max ono-max deleted the fix-bug branch January 10, 2022 00:55
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

Successfully merging this pull request may close these issues.

2 participants