akr
add309c496
Replace Kernel#pp after PP class is defined.
Avoid a race condition which a context switch
occur after replacing Kernel#pp but before
defining PP class.
Following patch, inserting sleep, makes
this problem reproducible.
```
Index: lib/pp.rb
===================================================================
--- lib/pp.rb (revision 60960)
+++ lib/pp.rb (working copy)
@@ -26,6 +26,7 @@ module Kernel
end
undef __pp_backup__ if method_defined?(:__pp_backup__)
module_function :pp
+ sleep 1 # thread context switch
end
##
```
With the above patch, "uninitialized constant Kernel::PP" can
happen as as follows.
```
% ./ruby -w -Ilib -e '
t1 = Thread.new {
Thread.current.report_on_exception = true
pp :foo1
}
t2 = Thread.new {
Thread.current.report_on_exception = true
sleep 0.5
pp :foo2
}
t1.join rescue nil
t2.join rescue nil
'
#<Thread:0x000055dbf926eaa0@-e:6 run> terminated with exception:
Traceback (most recent call last):
3: from -e:9:in `block in <main>'
2: from /home/ruby/tst2/ruby/lib/pp.rb:22:in `pp'
1: from /home/ruby/tst2/ruby/lib/pp.rb:22:in `each'
/home/ruby/tst2/ruby/lib/pp.rb:23:in `block in pp': uninitialized constant Kernel::PP (NameError)
:foo1
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-01 10:48:29 +00:00
..
2017-11-01 23:29:38 +00:00
2017-08-02 15:10:38 +00:00
2017-10-21 09:53:52 +00:00
2017-11-24 11:00:10 +00:00
2017-11-07 20:13:48 +00:00
2017-10-22 11:27:06 +00:00
2017-11-27 10:45:27 +00:00
2017-11-02 20:06:38 +00:00
2017-10-08 07:00:01 +00:00
2017-10-22 16:03:57 +00:00
2017-11-28 22:30:28 +00:00
2017-10-08 07:00:01 +00:00
2017-09-06 07:56:41 +00:00
2017-10-21 14:40:03 +00:00
2017-10-31 01:37:37 +00:00
2017-11-01 23:29:38 +00:00
2017-11-01 23:29:38 +00:00
2017-09-14 02:01:36 +00:00
2017-09-12 08:38:06 +00:00
2017-09-12 08:38:06 +00:00
2017-10-21 14:40:03 +00:00
2017-03-01 11:37:30 +00:00
2017-08-25 15:47:04 +00:00
2017-10-21 15:02:46 +00:00
2017-06-19 13:03:06 +00:00
2017-10-20 07:03:11 +00:00
2017-09-15 17:00:49 +00:00
2017-09-02 02:05:34 +00:00
2017-10-21 13:34:19 +00:00
2017-10-21 14:40:03 +00:00
2017-12-01 03:54:49 +00:00
2017-07-20 16:47:26 +00:00
2017-11-20 12:57:08 +00:00
2017-10-08 07:00:01 +00:00
2017-10-08 07:00:01 +00:00
2017-10-21 07:00:58 +00:00
2017-10-21 06:22:53 +00:00
2017-07-24 01:56:04 +00:00
2017-10-24 18:08:15 +00:00
2017-12-01 10:48:29 +00:00
2017-05-20 10:21:44 +00:00
2017-11-27 10:45:24 +00:00
2017-10-21 13:58:31 +00:00
2017-11-28 22:30:28 +00:00
2017-09-14 02:01:36 +00:00
2017-10-21 12:34:13 +00:00
2017-10-25 07:28:22 +00:00
2017-11-22 21:13:51 +00:00
2017-10-08 07:00:01 +00:00
2017-10-17 12:40:00 +00:00
2017-10-08 07:00:01 +00:00
2017-10-20 01:03:18 +00:00
2017-11-17 15:08:03 +00:00
2017-11-15 08:02:09 +00:00
2017-10-08 07:00:01 +00:00
2017-07-05 09:05:53 +00:00
2017-10-24 18:08:00 +00:00