[#99115] [Ruby master Bug#17023] How to prevent String memory to be relocated in ruby-ffi — larskanis@...
Issue #17023 has been reported by larskanis (Lars Kanis).
22 messages
2020/07/10
[#99375] [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings — merch-redmine@...
Issue #17055 has been reported by jeremyevans0 (Jeremy Evans).
29 messages
2020/07/28
[#101207] [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings
— merch-redmine@...
2020/12/02
Issue #17055 has been updated by jeremyevans0 (Jeremy Evans).
[#101231] Re: [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings
— Austin Ziegler <halostatue@...>
2020/12/03
What does this mean?
[ruby-core:99313] [Ruby master Bug#17048] Calling initialize_copy on live modules leads to crashes
From:
XrXr@...
Date:
2020-07-24 17:23:59 UTC
List:
ruby-core #99313
Issue #17048 has been updated by alanwu (Alan Wu).
I'm not proposing that we remove `initialize_copy`, but to make it raise when the receiver has children. So this is what it would look like:
```ruby
module A
end
A.send(:initialize_copy, Module.new) # fine, no one inherits from A
class B
include A
A.send(:initialize_copy, Module.new) # raise, since A now has one child
end
```
Admittedly this proposed behavior is designed to sidestep the problem that the current implementation has.
Though maybe it's fine since this is a seldom used private method and other Ruby implementations don't have to follow this behavior?
Now that you've mentioned it, removing the method and moving the logic into `Module#{dup,clone}` feels like the cleanest solution. It's more likely to be a breaking change though.
----------------------------------------
Bug #17048: Calling initialize_copy on live modules leads to crashes
https://bugs.ruby-lang.org/issues/17048#change-86707
* Author: alanwu (Alan Wu)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.8.0dev (2020-07-23T14:44:25Z master 098e8c2873) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Here's a repro script
```ruby
loop do
m = Module.new do
prepend Module.new
def hello
end
end
klass = Class.new { include m }
m.send(:initialize_copy, Module.new)
GC.start
klass.new.hello rescue nil
end
```
Here's a script that shows that it has broken semantics even
when it happens to not crash.
```ruby
module A
end
class B
include A
end
module C
Const = :C
end
module D
Const = :D
end
A.send(:initialize_copy, C)
p B::Const # :C, makes sense
A.send(:initialize_copy, D)
p B::Const # :D, makes sense
A.send(:initialize_copy, Module.new)
p (begin B::Const rescue NameError; 'NameError' end) # NameError, makes sense
A.send(:initialize_copy, C)
p B::Const # still NameErorr. Weird
```
This example shows that the problem exists [as far back as 2.0.0](https://wandbox.org/permlink/4dVDY9sNXJ803jh8).
I think the easiest way to fix this is to forbid calling `:initialize_copy`
on modules that have children. Another option is to try to decide on
the semantics of this. Though I don't think it's worth the effort as this
has been broken for a long time and people don't seem to to be using it.
Thoughts?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>