[ruby-core:112706] [Ruby master Bug#19480] invalid keeping_mutexes: Attempt to unlock a mutex which is not locked with fiber scheduler.
From:
"ioquatix (Samuel Williams) via ruby-core" <ruby-core@...>
Date:
2023-03-07 06:08:43 UTC
List:
ruby-core #112706
Issue #19480 has been reported by ioquatix (Samuel Williams).
----------------------------------------
Bug #19480: invalid keeping_mutexes: Attempt to unlock a mutex which is not locked with fiber scheduler.
https://bugs.ruby-lang.org/issues/19480
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: ioquatix (Samuel Williams)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN
----------------------------------------
The following program has a race condition due to IO write locks:
```ruby
#!/usr/bin/env ruby
require_relative 'lib/async'
def wait_for_interrupt(thread_index, repeat)
sequence = []
events = Thread::Queue.new
reactor = Async::Reactor.new
thread = Thread.new do
if events.pop
puts "#{thread_index}+#{repeat} Sending Interrupt!"
reactor.interrupt
end
end
reactor.async do
events << true
puts "#{thread_index}+#{repeat} Reactor ready!"
# Wait to be interrupted:
sleep(1)
puts "#{thread_index}+#{repeat} Missing interrupt!"
end
reactor.run
thread.join
end
64.times.map do |thread_index|
Thread.new do
1000.times do |repeat|
wait_for_interrupt(thread_index, repeat)
end
end
end.each(&:join)
```
The error manifests:
```
58+407 Reactor ready!
58+407 Sending Interrupt!
46+396 Sending Interrupt!
58+408 Sending Interrupt!
46+397 Reactor ready!
#<Thread:0x00007f9f681ca8e0 ./test-segfault.rb:11 run> terminated with exception (report_on_exception is true):
52+425 Sending Interrupt!
/home/samuel/Projects/socketry/async/lib/async/scheduler.rb:131:in `unblock': undefined method `wakeup' for nil:NilClass (NoMethodError)
@selector.wakeup
^^^^^^^
from ./test-segfault.rb:13:in `write'
from ./test-segfault.rb:13:in `puts'
from ./test-segfault.rb:13:in `puts'
from ./test-segfault.rb:13:in `block in wait_for_interrupt'
[BUG] invalid keeping_mutexes: Attempt to unlock a mutex which is not locked
ruby 3.2.1 (2023-02-08 revision 31819e82c8) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0001 p:---- s:0003 e:000002 DUMMY [FINISH]
-- C level backtrace information -------------------------------------------
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(rb_print_backtrace+0xd) [0x560fabaeff41] /home/samuel/src/ruby-3.2.1/vm_dump.c:785
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(rb_vm_bugreport) /home/samuel/src/ruby-3.2.1/vm_dump.c:1080
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(bug_report_end+0x0) [0x560fabca13ab] /home/samuel/src/ruby-3.2.1/error.c:790
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(rb_bug_without_die) /home/samuel/src/ruby-3.2.1/error.c:790
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(die+0x0) [0x560fab8d73b8] /home/samuel/src/ruby-3.2.1/error.c:798
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(rb_bug) /home/samuel/src/ruby-3.2.1/error.c:800
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(thread_start_func_2+0x630) [0x560faba84fa0] /home/samuel/src/ruby-3.2.1/thread.c:434
/home/samuel/.rubies/ruby-3.2.1/bin/ruby(thread_start_func_1+0xdb) [0x560faba857ab] /home/samuel/src/ruby-3.2.1/thread_pthread.c:1170
/usr/lib/libc.so.6(0x7f9f78321bb5) [0x7f9f78321bb5]
/usr/lib/libc.so.6(0x7f9f783a3d90) [0x7f9f783a3d90]
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/