Debugging Async tasks yields `RuntimeError: running is given, but running`
還沒有人認領這個 Issue。
評估
研究方向
Reproduce the example with Ruby 3.1.0, rdbg 1.4.0, and async 2.0.0, using breakpoints on both puts calls. Start with debug/thread_client.rb around set_mode and wait_next_action_, then follow the breakpoint path through debug/breakpoint.rb. Done means the same asynchronous debugging flow continues without raising RuntimeError: running is given, but running.
由索引模型根據 Issue 內容生成。
描述
Your environment
ruby -v: ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin20]rdbg -v: rdbg 1.4.0
Describe the bug
Debugging programs with the Async library often leads to RuntimeError: running is given, but running
To Reproduce
Install async 2.0.0:
gem install async
Create ruby script async_debug_test_case.rb as follows:
require 'async'
Async do |t|
t.async do
puts "1\n"
end
t.async do
puts "2\n"
end
end
Run rdbg, set breakpoints on both putss, and continue until error is raised. See output below:
rdbg scratch/async_debug_test_case.rb
[1, 10] in scratch/async_debug_test_case.rb
=> 1| require 'async'
2|
3| Async do |t|
4| t.async do
5| puts "1\n"
6| end
7| t.async do
8| puts "2\n"
9| end
=>#0 <main> at scratch/async_debug_test_case.rb:1
(rdbg) b 5 # break command
#0 BP - Line /Users/machty/code/exc/rails/scratch/async_debug_test_case.rb:5 (line)
(rdbg) b 8 # break command
#1 BP - Line /Users/machty/code/exc/rails/scratch/async_debug_test_case.rb:8 (line)
(rdbg) c # continue command
[1, 10] in scratch/async_debug_test_case.rb
1| require 'async'
2|
3| Async do |t|
4| t.async do
=> 5| puts "1\n"
6| end
7| t.async do
8| puts "2\n"
10| end
=>#0 block in <main> (2 levels) at scratch/async_debug_test_case.rb:5
#1 block in schedule at ~/.gem/ruby/3.1.0/gems/async-2.0.0/lib/async/task.rb:258
Stop by #0 BP - Line /Users/machty/code/exc/rails/scratch/async_debug_test_case.rb:5 (line)
(rdbg) c # continue command
[3, 11] in scratch/async_debug_test_case.rb
3| Async do |t|
4| t.async do
5| puts "1\n"
6| end
7| t.async do
=> 8| puts "2\n"
9| end
10| end
11|
=>#0 block in <main> (2 levels) at scratch/async_debug_test_case.rb:8
#1 block in schedule at ~/.gem/ruby/3.1.0/gems/async-2.0.0/lib/async/task.rb:258
Stop by #1 BP - Line /Users/machty/code/exc/rails/scratch/async_debug_test_case.rb:8 (line)
1
(rdbg) c # continue command
["DEBUGGER Exception: /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:986",
#<RuntimeError: running is given, but running>,
["/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:115:in `set_mode'",
"/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:698:in `wait_next_action_'",
"/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:676:in `wait_next_action'",
"/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:284:in `suspend'",
"/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:217:in `on_breakpoint'",
"/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/breakpoint.rb:65:in `suspend'",
"/Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/breakpoint.rb:157:in `block in setup'",
"scratch/async_debug_test_case.rb:8:in `block (2 levels) in <main>'",
"/Users/machty/.gem/ruby/3.1.0/gems/async-2.0.0/lib/async/task.rb:258:in `block in schedule'"]]
0.0s error: Async::Task [oid=0x5c8] [ec=0x5dc] [pid=34553] [2022-01-12 04:52:04 -0400]
| RuntimeError: running is given, but running
| → /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:115 in `set_mode'
| /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:698 in `wait_next_action_'
| /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:676 in `wait_next_action'
| /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:284 in `suspend'
| /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/thread_client.rb:217 in `on_breakpoint'
| /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/breakpoint.rb:65 in `suspend'
| /Users/machty/.rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/debug-1.4.0/lib/debug/breakpoint.rb:157 in `block in setup'
| scratch/async_debug_test_case.rb:8 in `block (2 levels) in <main>'
| /Users/machty/.gem/ruby/3.1.0/gems/async-2.0.0/lib/async/task.rb:258 in `block in schedule'
Expected behavior
Debugging should not crash.
Additional context
I can't replicate this issue using pure Fibers, so I suspect this has something to do with Ruby's new Fiber Scheduler interface and the way the Async library uses it. Note that simpler test cases using a single test cases involving one task don't seem to cause the rror.
- 主要語言
- Ruby
- 星號
- 1.3k
- 分支
- 146
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
ruby/debug 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 68/100
-
Support exceptionOptions in setExceptionBreakpoints to catch arbitrary exception classes via DAP 未關閉
難度 4/5 3-5 天 新手友好度 55/100
-
難度 3/5 1-2 天 新手友好度 45/100
-
難度 4/5 3-5 天 新手友好度 52/100
-
難度 4/5 3-5 天 新手友好度 35/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 75/100
palladius/rails8-app-on-gcp#145 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
難度 2/5 1-3 小時 新手友好度 70/100
riscv/riscv-unified-db#2624 · 1 個 reaction ·
-
難度 1/5 1 小時以內 新手友好度 88/100
-
難度 2/5 1-3 小時 新手友好度 78/100