[#78633] ruby/spec needs help from CRuby committers — Benoit Daloze <eregontp@...>
Currently, ruby/spec is maintained mostly by individuals and enjoys the
13 messages
2016/12/13
[#78963] Re: ruby/spec needs help from CRuby committers
— Urabe Shyouhei <shyouhei@...>
2017/01/04
I did ask attendees of last developer meeting to join this
[#78642] Re: ruby/spec needs help from CRuby committers
— Eric Wong <normalperson@...>
2016/12/14
Benoit Daloze <eregontp@gmail.com> wrote:
[ruby-core:78742] [Ruby trunk Bug#12907] rb_respond_to() return value is incorrect
From:
eugene@...
Date:
2016-12-20 09:43:06 UTC
List:
ruby-core #78742
Issue #12907 has been updated by Eugene Pimenov.
ruby -v changed from 2.3.0, 2.3.1 to 2.3.0-3
We did hit this bug on our system and did a deep dive in it yesterday.
The code to reproduce the issue is:
~~~ c
rb_respond_to(rb_eval_string("BasicObject.new"), rb_intern("anythinghere"))
~~~
It always returns ``1`` (``TRUE``) in ruby 2.3.x. It's caused by [[the following line]](https://github.com/ruby/ruby/blob/c91cb76f8d84b2963f6ede2ef445ad46a6104216/vm_method.c#L1919). Because ``respond_to`` method doesn't exist in ``BasicObject``. The correct code was reverted in [[r55869 ]](https://github.com/ruby/ruby/commit/53369d7e4dab675ede11b584ffc003e51ea62672#diff-6cea7716df08f2b7fdc5fb30c7963884R1919) because it breaks `ActiveSupport` 4.1.
As far as I can tell the issue is fixed in trunk and 2.4.x betas.
----------------------------------------
Bug #12907: rb_respond_to() return value is incorrect
https://bugs.ruby-lang.org/issues/12907#change-62115
* Author: Peter Ohler
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.3.0-3
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
As of Ruby 2.3.0 rb_respond_to incorrectly reports non-zero for methods that are not supported. This occurs with subclasses of BasicObject. This occurs with Oj when but should occur with other C code. A simple sample that demonstrates the failure in below. It works fine on all versions of Ruby until 2.3.0.
require 'oj'
class A < BasicObject
def initialize(data)
@data = data
end
end
a = A.new("xyz")
json = Oj.dump(a, mode: :compat, use_to_json: true)
#=> NoMethodError: undefined method `to_hash' for #<A:0x007fae03de1dc8>
In the C code the rb_respond_to() function is called to determine if an instance of A responds to "to_hash". 1 is returned in Ruby 2.3.x while previous versions correctly returned 0.
--
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>