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

Remote Debugger Hanging Up Crashes Byebug #274

Closed
LtSquigs opened this issue May 31, 2016 · 2 comments
Closed

Remote Debugger Hanging Up Crashes Byebug #274

LtSquigs opened this issue May 31, 2016 · 2 comments

Comments

@LtSquigs
Copy link

Problem: If the socket for a remote connection is closed after connecting to the remote server, further writes/reads will crash the server.

Version: 9.05

Steps to Reproduce:

  1. Run this example program
require 'byebug'
require 'byebug/core'

Byebug.wait_connection = true
Byebug.start_server 'localhost', ENV.fetch("BYEBUG_SERVER_PORT", 1048).to_i

puts 'a'
byebug
puts 'b'
sleep 5
puts 'c'
byebug
puts 'd'
  1. Connect to this using the remote debugger
  2. When it encounters the first byebug statement, continue
  3. While the program sleeps, terminate the byebug CLI (CTRL + C)
  4. After the program wakes up, when it hits the second byebug statement, it will crash with an Errno::EPIPE exception

Expectation: The server should either detect when the socket is closed or if an EPIPE exception has happened, and stop communicating over the socket (treat it as if there was no connection).

While the above example is very arbitrary, a more real world example of where this happens: debugging remote rails applications. If you have a byebug statement in a controller, connect to it remotely, debug the area, then the debugger closes for some reason you will have a crash.

Fixing this will also allow users to "detach" the debugger by interrupting it between byebug calls (useful if you have a constantly running dev server).

@deivid-rodriguez
Copy link
Owner

deivid-rodriguez commented Oct 9, 2016

@LtSquigs Thanks for the great report. Want to try fixing it? 😄

@deivid-rodriguez
Copy link
Owner

@LtSquigs This should be fixed by #406, feel free to give the branch a try and give feedback!

yui-knk added a commit to yui-knk/byebug that referenced this issue Dec 8, 2018
This test case was introduced as a regression test of
deivid-rodriguez#274
in deivid-rodriguez#406.

The description of issues/274 says an exception will be raised
if the byebug CLI is terminated when main program is sleeping.

Before this commit there are 2 breakpoints (`byebug` method call)
before `sleep 3` and `"cont"` is called once because the arugment of
`remote_debug_connect_and_interrupt` is `"cont"`.
I think this is not intended.

And the method name of test case is `program_with_two_breakpoints`,
on the other hand the program had 3 breakpoints (`byebug`).
deivid-rodriguez pushed a commit that referenced this issue Dec 8, 2018
This test case was introduced as a regression test of
#274
in #406.

The description of issues/274 says an exception will be raised
if the byebug CLI is terminated when main program is sleeping.

Before this commit there are 2 breakpoints (`byebug` method call)
before `sleep 3` and `"cont"` is called once because the arugment of
`remote_debug_connect_and_interrupt` is `"cont"`.
I think this is not intended.

And the method name of test case is `program_with_two_breakpoints`,
on the other hand the program had 3 breakpoints (`byebug`).
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

2 participants