https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112012-11-14T11:14:42ZRuby Issue Tracking SystemRuby master - Bug #7348: marshaling an object by a float does not workhttps://redmine.ruby-lang.org/issues/7348?journal_id=328852012-11-14T11:14:42Zmrkn (Kenta Murata)muraken@gmail.com
<ul></ul><p>irb(main):006:0> e = Object.new<br>
irb(main):007:0> Marshal.load(Marshal.dump([[2.0e-100, e], [e]]))<br>
=> [[2.0e-100, #<a href="Object:0x007fa45a10bc28" class="external">Object:0x007fa45a10bc28</a>], [#<a href="Object:0x007fa45a10bc28" class="external">Object:0x007fa45a10bc28</a>]]</p>
<p>Therefore it is related to flonum.</p> Ruby master - Bug #7348: marshaling an object by a float does not workhttps://redmine.ruby-lang.org/issues/7348?journal_id=328862012-11-14T11:32:33Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li></ul> Ruby master - Bug #7348: marshaling an object by a float does not workhttps://redmine.ruby-lang.org/issues/7348?journal_id=329532012-11-16T14:38:32Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>File</strong> <a href="/attachments/3252">flonum_marshal_dump.patch</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/3252/flonum_marshal_dump.patch">flonum_marshal_dump.patch</a> added</li><li><strong>Category</strong> set to <i>core</i></li><li><strong>Assignee</strong> changed from <i>ko1 (Koichi Sasada)</i> to <i>nagachika (Tomoyuki Chikanaga)</i></li><li><strong>Target version</strong> set to <i>2.0.0</i></li></ul><p>hello,</p>
<p>I've investigated about this issue.<br>
When flonum is introduced at r36798, flonum is treated as immediate value in w_object(), but is should treated as reference value.<br>
I will attach a patch. This patch introduce a trivial incompatibility. All flonum of same value are dumped as reference of same Float object. I don't think this is not a practical problem.</p>
<p>(on flonum supported environment)<br>
a = [2.0, 2.0, 2.0]<br>
File.write("dump.txt", Marshal.dump(a))</p>
<p>(on flonum not supported environment)<br>
a = Marshal.load(File.read("dump.txt"))<br>
a.map{|f| f.object_id} # => [70180445290980, 70180445290980, 70180445290980]</p>
<p>If there's no objection, I'll check-in it tonight (in JST).</p> Ruby master - Bug #7348: marshaling an object by a float does not workhttps://redmine.ruby-lang.org/issues/7348?journal_id=329702012-11-17T00:56:03Znagachika (Tomoyuki Chikanaga)nagachika00@gmail.com
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r37687.<br>
Aaron, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>
<p>marshal.c (w_object): add flonum to arg->data to keep reference index<br>
consistency. <a href="/issues/7348">[ruby-core:49323]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: marshaling an object by a float does not work (Closed)" href="https://redmine.ruby-lang.org/issues/7348">#7348</a>]</p>
</li>
<li>
<p>test/ruby/test_marshal.rb: add a test for above.</p>
</li>
</ul> Ruby master - Bug #7348: marshaling an object by a float does not workhttps://redmine.ruby-lang.org/issues/7348?journal_id=419112013-09-21T00:25:17Zzzak (zzak _)
<ul></ul><p>commit miss orz</p>