Forum: Ruby-core [ruby-trunk - Bug #7383][Open] Use stricter cache check in load.c

Posted by Yura Sokolov (funny_falcon)
on 2012-11-18 11:10
(Received via mailing list)
Issue #7383 has been reported by funny_falcon (Yura Sokolov).

----------------------------------------
Bug #7383: Use stricter cache check in load.c
https://bugs.ruby-lang.org/issues/7383

Author: funny_falcon (Yura Sokolov)
Status: Open
Priority: High
Assignee: h.shirosaki (Hiroshi Shirosaki)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-18 trunk 37708) [x86_64-linux]


rb_ary_shared_with_p does not react when #shift or #pop is called on 
original array.

This patch introduce rb_ary_dup_of_p , which makes more adequate check 
for duplicate
of array.

https://github.com/ruby/ruby/pull/216
https://github.com/ruby/ruby/pull/216.patch
Posted by h.shirosaki (Hiroshi Shirosaki) (Guest)
on 2012-11-19 14:56
(Received via mailing list)
Issue #7383 has been updated by h.shirosaki (Hiroshi Shirosaki).

File 0001-Fix-cache-validity-check-of-require.patch added

Yura, thank you.
Indeed rb_ary_shared_with_p does not react against #shift or #pop. 
Original array remains shared with the snapshot.
However, I think adding a check of array length would be sufficient for 
that. This fix has no performance impact, still O(1). I've attached a 
patch with tests.
Are there any reasons that such a strict check is needed?
----------------------------------------
Bug #7383: Use stricter cache check in load.c
https://bugs.ruby-lang.org/issues/7383#change-33097

Author: funny_falcon (Yura Sokolov)
Status: Open
Priority: High
Assignee: h.shirosaki (Hiroshi Shirosaki)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-11-18 trunk 37708) [x86_64-linux]


rb_ary_shared_with_p does not react when #shift or #pop is called on 
original array.

This patch introduce rb_ary_dup_of_p , which makes more adequate check 
for duplicate
of array.

https://github.com/ruby/ruby/pull/216
https://github.com/ruby/ruby/pull/216.patch
Posted by Yura Sokolov (funny_falcon)
on 2012-11-22 10:09
(Received via mailing list)
Hiroshi,

Adding size check is enough in this case.
But rb_ary_dup_of_p is more useful in the wild, I think.

With regards,
Yura

2012/11/19 h.shirosaki (Hiroshi Shirosaki) <h.shirosaki@gmail.com>
Posted by Hiroshi Shirosaki (Guest)
on 2012-11-22 15:31
(Received via mailing list)
On Thu, Nov 22, 2012 at 6:09 PM,   <funny.falcon@gmail.com> wrote:
> Adding size check is enough in this case.
> But rb_ary_dup_of_p is more useful in the wild, I think.
>

OK. Then I'll apply my patch for now. If real issues were raised, I'll
consider your patch.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.