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

The debugger command doesn't seem to work when using multiple threads at the same time. #1027

Open
thijsnado opened this issue Oct 18, 2023 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@thijsnado
Copy link

Your environment

  • ruby -v: 3.2.2
  • rdbg -v: 1.8.0

Describe the bug

Doesn't seem to work well with multithreaded debugger statements. The program does not print out expected local variables and seems to hang forever after last continue statement.

To Reproduce

Given the following ruby code:

require "debug"

thr1 = Thread.new {
  hello = "world"

  debugger

  puts hello
}


thr2 = Thread.new {
  hello = "hello"

  debugger

  puts hello
}

thr1.join
thr2.join

The first time I reach a breakpoint it shows me in the hello = "hello" block. When I type out hello though it than jumps me to hello = "world" block. After typing out hello a second time, it prints out the string "hello" instead of "world". If I type continue it hangs forever after that. If I run the program without the debugger statements it doesn't hang.

Expected behavior
I would expect debugger to be somewhat threadsafe. Obviously debugger cannot necessarily control the order of these two debuggers. The second debug statement may execute first but I'd expect that the breakpoint would match the local variable and I'd expect typing continue would than make the program keep running and go to the next debugger statement or terminate the program if no more debugger statements.

@ko1
Copy link
Collaborator

ko1 commented Nov 14, 2023

Thank you. This code is great to reproduce the issue.
Honestly speaking current thread management is not strict and this is a time to consider strict management...

@ko1 ko1 added the bug Something isn't working label Dec 5, 2023
@ko1 ko1 modified the milestones: v1.9.0, v1.9.1 Dec 5, 2023
@ko1
Copy link
Collaborator

ko1 commented Dec 11, 2023

I couldn't complete to solve this issue so I'll try it on 1.9.1

@ko1 ko1 modified the milestones: v1.9.1, v1.9.2 Dec 22, 2023
@sammyhenningsson
Copy link

I can't continue after hitting a breakpoint with Puma and I believe this might be the same issue. Just curious.. Is it a known issue that debug can't be used with puma due to this? Or am I doing something else wrong? (I've tried and failed on several rails projects. Changing to webrick makes it work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

3 participants