https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112016-05-06T04:50:07ZRuby Issue Tracking SystemRuby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=585072016-05-06T04:50:07Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>I can't reproduce it.</p>
<pre><code>$ gem2.3 install --user --no-doc activesupport
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: activesupport-4.2.6.gem (100%)
Successfully installed activesupport-4.2.6
2 gems installed
$ ruby2.3 -v -ractive_support/core_ext/numeric/time -e 'p Marshal.dump(1.day)'
ruby 2.3.1p112 (2016-04-26 revision 54768) [universal.x86_64-darwin15]
"\x04\bo:\x1CActiveSupport::Duration\a:\v@valuei\x03\x80Q\x01:\v@parts[\x06[\a:\tdaysi\x06"
</code></pre> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=585782016-05-11T12:38:29Zjeffreyc (Jeff C)
<ul></ul><p>Nobuyoshi Nakada wrote:</p>
<blockquote>
<p>I can't reproduce it.</p>
<pre><code>Successfully installed activesupport-4.2.6
</code></pre>
</blockquote>
<p>The regression appears to be specific to ActiveSupport 4.1.15. If I try ActiveSupport 4.2.6, <code>Marshal.dump</code> behaves as expected.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=593442016-06-24T09:48:37Zbakineggs (Dan Barry)
<ul></ul><p>Using Ruby 2.3, Marshal.dump(1.day) works with ActiveSupport 4.2.6 but not 4.1.15 because ActiveSupport::Duration inherits from BasicObject in 4.1.15 and Object in 4.2.6.</p>
<p>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?.</p>
<p>Here's a simple example:</p>
<pre><code>$ irb
2.3.1 :001 > class Wrapper < BasicObject
2.3.1 :002?> def initialize wrapped_object
2.3.1 :003?> @wrapped_object = wrapped_object
2.3.1 :004?> end
2.3.1 :005?> def method_missing *args, &block
2.3.1 :006?> @wrapped_object.public_send *args, &block
2.3.1 :007?> end
2.3.1 :008?> end
=> :method_missing
2.3.1 :009 > wrapped_string = Wrapper.new "foo"
=> "foo"
2.3.1 :010 > wrapped_string.respond_to? :marshal_dump
=> false
2.3.1 :011 > Marshal.dump wrapped_string
NoMethodError: undefined method `marshal_dump' for "foo":String
from (irb):6:in `public_send'
from (irb):6:in `method_missing'
from (irb):11:in `dump'
from (irb):11
from /Users/dan/.rvm/rubies/ruby-2.3.1/bin/irb:11:in `<main>'
2.3.1 :012 > class Wrapper
2.3.1 :013?> def respond_to? *args, &block
2.3.1 :014?> super
2.3.1 :015?> end
2.3.1 :016?> end
=> :respond_to?
2.3.1 :017 > wrapped_string.respond_to? :marshal_dump
=> false
2.3.1 :018 > Marshal.dump wrapped_string
=> "\x04\bo:\fWrapper\x06:\x14@wrapped_objectI\"\bfoo\x06:\x06ET"
</code></pre>
<p>In Ruby 2.2 and earlier, Marshal.dump(wrapped_string) would work without needing to define a respond_to? method on Wrapper.</p>
<p>It's bad practice to define a method_missing without a corresponding respond_to_missing?, but even with a respond_to_missing? method defined, we still need a respond_to? in order for Marshal.dump to work:</p>
<pre><code>2.3.1 :001 > class Wrapper < BasicObject
2.3.1 :002?> def initialize wrapped_object
2.3.1 :003?> @wrapped_object = wrapped_object
2.3.1 :004?> end
2.3.1 :005?> def method_missing *args, &block
2.3.1 :006?> @wrapped_object.public_send *args, &block
2.3.1 :007?> end
2.3.1 :008?> def respond_to_missing? method_name, include_private = false
2.3.1 :009?> @wrapped_object.respond_to? method_name, include_private
2.3.1 :010?> end
2.3.1 :011?> end
=> :respond_to_missing?
2.3.1 :012 > wrapped_string = Wrapper.new "foo"
=> "foo"
2.3.1 :013 > wrapped_string.respond_to? :marshal_dump
=> false
2.3.1 :014 > Marshal.dump wrapped_string
NoMethodError: undefined method `marshal_dump' for "foo":String
from (irb):6:in `public_send'
from (irb):6:in `method_missing'
from (irb):14:in `dump'
from (irb):14
from /Users/dan/.rvm/rubies/ruby-2.3.1/bin/irb:11:in `<main>'
</code></pre>
<p>One way to achieve the expected behavior would be to change vm_respond_to() so that it calls method_missing(:respond_to?, priv) when it can't find a method table entry for respond_to? instead of just returning true.</p>
<p>I'd be happy to make this change if someone on the core team can let me know if my suggestion is the right way to handle this or if there's a different way things should be changed.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=593482016-06-24T17:33:41Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Closed</i></li></ul><p>Applied in changeset r55500.</p>
<hr>
<p>No respond_to? as if the default definition</p>
<ul>
<li>vm_method.c (vm_respond_to): try method_missing if respond_to?<br>
is undefined, as if it is the default definition.<br>
<a href="/issues/12353">[ruby-core:75377]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] (Closed)" href="https://redmine.ruby-lang.org/issues/12353">#12353</a>]</li>
</ul> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=599282016-08-04T07:15:07Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Backport</strong> changed from <i>2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN</i> to <i>2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED</i></li></ul> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=600662016-08-11T18:58:16Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Backport</strong> changed from <i>2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED</i> to <i>2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE</i></li></ul><p>ruby_2_3 r55869 merged revision(s) 54142,55500.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=601792016-08-17T15:08:47Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul><p>I found this backport broke ActiveSupport::Duration of ActiveSupport 4.1.x:</p>
<pre><code>% ruby -e '
gem "activesupport", "4.1.16"
require "active_support/time"
10.days'
/PREFIX/lib/ruby/gems/2.3.0/gems/activesupport-4.1.16/lib/active_support/core_ext/numeric/time.rb:50:in `*': ActiveSupport::Duration can't be coerced into Fixnum (TypeError)
from /PREFIX/lib/ruby/gems/2.3.0/gems/activesupport-4.1.16/lib/active_support/core_ext/numeric/time.rb:50:in `days'
from -e:4:in `<main>'
</code></pre>
<p>This could be fixed by defining <code>respond_to_missing?</code> as follows:</p>
<pre><code>class ActiveSupport::Duration
def respond_to_missing?(name, private = false)
value.respond_to?(name, false)
end
end
</code></pre>
<p>However, some gems such as Devise call the time unit methods while they are required, and it is not always easy for a user application to monkey-patch this if it uses Bundler to require all gems at once.</p>
<p>Now, it has already been announced that Rails 4.1 is going to see EOL in no distant future, but considering Rails 4.1.16 was released pretty recently, I think we should probably cooperate with the Rails team and make sure the upcoming 2.3.2 release will not break existing Rails 4.1 applications without prior notice.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=602132016-08-21T03:01:02Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul></ul><p>r55500 breaks <code>1.days</code>, while it fixed Marshal.dump with object which respond to marshal_dump with method_missing.<br>
Even though it's obviously a bug-fix, introduce more critical issue as for activesupport-4.1.x.<br>
I think I should revert r55869 for a while.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=602792016-08-25T10:43:36Zknu (Akinori MUSHA)knu@ruby-lang.org
<ul></ul><p>So, can we revert the backport?</p>
<p>This issue spotted a feature bug and it got fixed in trunk, but the original problem (<code>Marshall.dump(1.day)</code> does not work with ruby 2.3+ and activesupport 4.1.x) was not solved by the fix, causing a more serious problem in terms of backward compatibility.</p>
<p>As was confirmed it works with activesupport 4.2+, so I think it will be fine if Ruby 2.4 and later do not run Rails 4.1, since it's almost certain that the 2.4 series will start off after 4.1 effectively reaches its EOL.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=603042016-08-27T15:41:19Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset ruby_2_3|r56022.</p>
<hr>
<ul>
<li>
<p>vm_method.c: revert r55869. it breaks Integer#days with<br>
ActiveSupport-4.1.x. <a href="/issues/12353">[ruby-core:76949]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] (Closed)" href="https://redmine.ruby-lang.org/issues/12353">#12353</a>]</p>
</li>
<li>
<p>test/ruby/test_marshal.rb: ditto.</p>
</li>
</ul> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=603052016-08-27T15:43:57Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li><li><strong>Backport</strong> changed from <i>2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE</i> to <i>2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED</i></li></ul><p>I reverted r55869 partially at r56022.<br>
And I keep opend this ticket because there's still problem with activesupport 4.1.x.</p> Ruby master - Bug #12353: Regression with Marshal.dump on ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]https://redmine.ruby-lang.org/issues/12353?journal_id=809482019-08-23T22:10:43Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul>