Debugging Async tasks yields `RuntimeError: running is given, but running`
まだ誰も着手していません。
評価
調査の方向性
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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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時間 初心者へのやさしさ 76/100
TheOdinProject/curriculum#31408 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
notch8/utk_knapsack#148 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
Homebrew/homebrew-cask#288729 · コメント 1 件 ·
-
Documentation issues オープン
難易度 2/5 1〜2日 初心者へのやさしさ 72/100
-
feature
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
betagouv/acces-cible#722 ·