ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:91519] [Ruby trunk Bug#15599] Mixing autoload and require causes deadlockand incomplete definition.
       [not found] <redmine.issue-15599.20190212134045@ruby-lang.org>
@ 2019-02-12 13:40 ` akr
  0 siblings, 0 replies; only message in thread
From: akr @ 2019-02-12 13:40 UTC (permalink / raw)
  To: ruby-core

Issue #15599 has been reported by akr (Akira Tanaka).

----------------------------------------
Bug #15599: Mixing autoload and require causes deadlock and incomplete definition.
https://bugs.ruby-lang.org/issues/15599

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-02-11 trunk 67049) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I found that mixing autoload and require causes deadlock and incomplete definition.

```
% cat a.rb 
class A
  def a1() end
end
% cat base.rb 
autoload :A, './a'

t1 = Thread.new { p A.instance_methods(false) }
t2 = Thread.new { require './a' }

t1.join
t2.join
% ruby base.rb 
Traceback (most recent call last):
	1: from base.rb:6:in `<main>'
base.rb:6:in `join': No live threads left. Deadlock? (fatal)
3 threads, 3 sleeps current:0x000055cc6943fde0 main thread:0x000055cc6935f4b0
* #<Thread:0x000055cc6938f190 sleep_forever>
   rb_thread_t:0x000055cc6935f4b0 native:0x00007f58d256eb40 int:0
   base.rb:6:in `join'
   base.rb:6:in `<main>'
* #<Thread:0x000055cc6968cfc8@base.rb:3 sleep_forever>
   rb_thread_t:0x000055cc69736180 native:0x00007f58ce7b3700 int:0 mutex:0x000055cc6943fde0 cond:1
    depended by: tb_thread_id:0x000055cc6935f4b0
   /home/akr/ruby/o0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:54:in `require'
   /home/akr/ruby/o0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:54:in `require'
   base.rb:3:in `block in <main>'
* #<Thread:0x000055cc6968ccd0@base.rb:4 sleep_forever>
   rb_thread_t:0x000055cc6943fde0 native:0x00007f58ce5b1700 int:0
   /tmp/a/a.rb:1:in `<top (required)>'
   /home/akr/ruby/o0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:54:in `require'
   /home/akr/ruby/o0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:54:in `require'
   base.rb:4:in `block in <main>'
% ruby base.rb
[:a1]
% ruby base.rb
[]
```

The last run which prints [] means incomplete definition of A which a1 method is not defined.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-12 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-15599.20190212134045@ruby-lang.org>
2019-02-12 13:40 ` [ruby-core:91519] [Ruby trunk Bug#15599] Mixing autoload and require causes deadlockand incomplete definition akr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).