Project

General

Profile

Backport #8043

Marshal will dump some object with singleton methods

Added by marcandre (Marc-Andre Lafortune) about 6 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:53206]

Description

=begin
The check for "dumpability" is incorrect:

o = Object.new
def o.foo; end
Marshal.dump(o) # => TypeError: singleton can't be dumped
o.singleton_class.send :prepend, Enumerable
Marshal.dump(o) # => "\x04\be:\x0FEnumerablee:\vObjecto;\x06\0", should fail

=end

Associated revisions

Revision b3265c0e
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 39650
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

Revision 39650
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

Revision 39650
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

Revision 39650
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

Revision 39650
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

Revision 39650
Added by nobu (Nobuyoshi Nakada) about 6 years ago

marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]

Revision 279b256d
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

merge revision(s) 39650: [Backport #8043]

* marshal.c (w_extended): check for prepended object.
  [ruby-core:53206] [Bug #8043]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 40087
Added by nagachika (Tomoyuki Chikanaga) about 6 years ago

merge revision(s) 39650: [Backport #8043]

* marshal.c (w_extended): check for prepended object.
  [ruby-core:53206] [Bug #8043]

History

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Description updated (diff)

But extended objects are allowed, aren't they?

Updated by marcandre (Marc-Andre Lafortune) about 6 years ago

My understanding is that objects whose singleton classes have included / prepended classes should be dumpable & loadable, but if the singleton class itself has proper instance methods it can't be dumped.

In the example I gave, the first TypeError is ok, since o's singleton class has a :foo method.

Prepending a module should not make it suddenly dumpable.

The check for this is in w_extended is incorrect. If I'm not mistaken, it assumes that the singleton class is first in the ancestry chain, which is no longer necessarily the case.

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

Thank you, I misread that `o' would be different object.
I'll fix it.

#4

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39650.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


marshal.c: check for prepended

  • marshal.c (w_extended): check for prepended object. [ruby-core:53206] [Bug #8043]
#5

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Category deleted (core)
  • Status changed from Closed to Assigned
  • Assignee set to nagachika (Tomoyuki Chikanaga)
  • Target version deleted (2.1.0)
#6

Updated by nagachika (Tomoyuki Chikanaga) about 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40087.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 39650: [Backport #8043]

* marshal.c (w_extended): check for prepended object.
  [ruby-core:53206] [Bug #8043]

Also available in: Atom PDF