Open docu-tyler-harris opened 1 year ago
Thank you for the report. It doesn't look related to #17 to me at first sight.
I wondered if there could be a problem when nesting calls to Timeout.timeout{}
but that doesn't seem an issue, the lock is not held during the block given to timeout
.
Could you try with Ruby 3.0+? That differs in that Mutex is owned per Fiber, faraday or byebug likely use Fibers.
Could you try to minimize the example to avoid depending on gems? That should help to understand where the problem is. It could be a bug that Mutex misbehaves on Windows on CRuby, but that seems unlikely.
I don't have a Windows dev env, so I cannot really investigate myself if it's not reproducible on Linux.
Thanks for checking.
It will likely take me a while to find time to simplify this further. Using any version of byebug/faraday reproduces the issue, and only on timeout versions >= 0.3.0. I have no idea why the API call through faraday is needed before this will repro
Ruby 3.0+ is a goal for us, but our mono repo has some gem dependencies keeping us on 2.7 for the time being. Currently I'm forcing a downgrade of timeout to 0.2.x to workaround the issue until we can find a better solution.
Ruby 3.0+ is a goal for us, but our mono repo has some gem dependencies keeping us on 2.7 for the time being. Currently I'm forcing a downgrade of timeout to 0.2.x to workaround the issue until we can find a better solution.
Could you try your repro above on Ruby 3.0 on Windows and reply here whether it's also affected or not? That shouldn't require much work.
FYI in case it is related to #17, see https://github.com/ruby/timeout/issues/17#issuecomment-1451761281 (i.e., that should be fixed in CRuby IMO, let's see how that issue evolves).
I am seeing it on Ruby 3.2 and timeout 0.4.1 (on Windows Server) using the above example.
1: require 'faraday'
2: require 'byebug'
3: temp = Faraday.get("https://google.com") # any api call, whether successful or not
4: byebug # *** while in byebug, tap up arrow several times to access Readline::HISTORY through byebug/interface
=> 5: exit 0
(byebug) C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timeout-0.4.1/lib/timeout.rb:181:in `synchronize': No live threads left. Deadlock? (fatal)
2 threads, 2 sleeps current:0x000001ab91efe660 main thread:0x000001ab91efe660
* #<Thread:0x000001ab91f99ff0 sleep_forever>
rb_thread_t:0x000001ab91efe660 native:0x0000000000000220 int:0
* #<Thread:0x000001ab99429fa0@Timeout stdlib thread C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timeout-0.4.1/lib/timeout.rb:98 sleep_forever>
rb_thread_t:0x000001ab98b2dbf0 native:0x0000000000000364 int:0
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timeout-0.4.1/lib/timeout.rb:181:in `block in timeout'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timeout-0.4.1/lib/timeout.rb:41:in `handle_timeout'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/timeout-0.4.1/lib/timeout.rb:195:in `timeout'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:430:in `read_2nd_character_of_key_sequence'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:408:in `block in read_io'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:390:in `loop'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:390:in `read_io'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:343:in `block in inner_readline'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:341:in `loop'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:341:in `inner_readline'
from C:/Ruby32-x64/lib/ruby/3.2.0/reline.rb:284:in `readline'
from C:/Ruby32-x64/lib/ruby/3.2.0/forwardable.rb:240:in `readline'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/interfaces/local_interface.rb:24:in `block in readline'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/interfaces/local_interface.rb:36:in `with_repl_like_sigint'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/interfaces/local_interface.rb:24:in `readline'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/interface.rb:71:in `prepare_input'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/interface.rb:55:in `read_input'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/interface.rb:38:in `read_command'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/processors/command_processor.rb:128:in `repl'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/processors/command_processor.rb:97:in `process_commands'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/processors/command_processor.rb:55:in `at_line'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/byebug-11.0.1/lib/byebug/context.rb:98:in `at_line'
This only occurs on Windows machines, to my knowledge and only in version 0.3.x
Script that reproduces this
timeout_error.rb
On a windows machine, run the script ./timeout_error.rb