[#84867] [Ruby trunk Bug#14357] thread_safe tests suite segfaults — v.ondruch@...

Issue #14357 has been reported by vo.x (Vit Ondruch).

11 messages 2018/01/15

[#84980] [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — hsbt@...

Issue #13618 has been updated by hsbt (Hiroshi SHIBATA).

10 messages 2018/01/23
[#85012] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — Eric Wong <normalperson@...> 2018/01/23

hsbt@ruby-lang.org wrote:

[ruby-core:84625] [Ruby trunk Bug#14266] Set#clone(freeze: false) makes frozen internal hash

From: merch-redmine@...
Date: 2018-01-04 03:52:59 UTC
List: ruby-core #84625
Issue #14266 has been updated by jeremyevans0 (Jeremy Evans).


I see two possible ways to fix this:

1) Switch to overriding `clone` instead of `initialize_clone` in such cases.

2) Make `clone(freeze: false)` call `initialize_clone(freeze: false)`, but have `clone` otherwise call `initialize_clone` without a keyword argument.  Make `Object#initialize_clone` accept and ignore the `freeze` keyword.  This way, if you override `initialize_clone` and don't have it accept the `freeze` keyword, `clone(freeze: false)` will raise an ArgumentError.  That's probably better than returning a unfrozen object with frozen instance variables.

----------------------------------------
Bug #14266: Set#clone(freeze: false) makes frozen internal hash
https://bugs.ruby-lang.org/issues/14266#change-69199

* Author: znz (Kazuhiro NISHIYAMA)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-01-01 trunk 61537) [x86_64-darwin16]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
```
% irb -r irb/completion --simple-prompt
>> require 'set'
=> true
>> set=Set[].freeze.clone(freeze: false)
=> #<Set: {}>
>> set.frozen?
=> false
>> set.instance_variable_get(:@hash).frozen?
=> true
```

In `Set#initialize_clone`, clone hash without freeze keyword argument.
But I think there is no easy way how to know freeze keyword argument value in `initialize_clone`.

```
  # Clone internal hash.
  def initialize_clone(orig)
    super
    @hash = orig.instance_variable_get(:@hash).clone
  end
```



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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next