The issue is that as of Ruby 2.3, Marshal.dump no longer works with objects that inherit from BasicObject and do not directly define a respond_to? method. This is because vm_respond_to() in vm_method.c returns true if it can not find a method table entry for the respond_to? method, so w_object() in marshal.c tries to call marshal_dump. In Ruby 2.2 and prior, rb_obj_respond_to() would just call respond_to? instead of checking for a method table entry, so method_missing could receive the respond_to?.
Before (on master)
$ ruby -Ilib -rasari -e "p Marshal.dump Asari::Collection.sandbox_fake"
/Users/andrew/Code/ruby/asari/lib/asari/collection.rb:77:in `method_missing': undefined method `marshal_dump' for []:Array (NoMethodError)
from -e:1:in `dump'
from -e:1:in `<main>'
This adds a workaround for the issue mentioned above by implementing respond_to? in Asari::Collection – Another solution might be to change Asari::Collection so it subclasses Object instead of BasicObject
Why
In Ruby 2.3 a regression was introduced in the code that checks if an object responds to a method.
More info: https://bugs.ruby-lang.org/issues/12353
Before (on master)
After (this branch)
What
This adds a workaround for the issue mentioned above by implementing
respond_to?
inAsari::Collection
– Another solution might be to changeAsari::Collection
so it subclassesObject
instead ofBasicObject