Forum: Ruby-core [ruby-trunk - Bug #8043][Open] Marshal will dump some object with singleton methods

0e610136db92027148906c92d57fdb36?d=identicon&s=25 marcandre (Marc-Andre Lafortune) (Guest)
on 2013-03-08 01:48
(Received via mailing list)
Issue #8043 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Bug #8043: Marshal will dump some object with singleton methods
https://bugs.ruby-lang.org/issues/8043

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: r39608


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
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-03-08 10:39
(Received via mailing list)
Issue #8043 has been updated by nobu (Nobuyoshi Nakada).

Description updated

But extended objects are allowed, aren't they?
----------------------------------------
Bug #8043: Marshal will dump some object with singleton methods
https://bugs.ruby-lang.org/issues/8043#change-37388

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: r39608


=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
0e610136db92027148906c92d57fdb36?d=identicon&s=25 marcandre (Marc-Andre Lafortune) (Guest)
on 2013-03-08 20:35
(Received via mailing list)
Issue #8043 has been updated by marcandre (Marc-Andre Lafortune).


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.
----------------------------------------
Bug #8043: Marshal will dump some object with singleton methods
https://bugs.ruby-lang.org/issues/8043#change-37400

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: r39608


=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
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (nobu)
on 2013-03-09 00:18
(Received via mailing list)
Issue #8043 has been updated by nobu (Nobuyoshi Nakada).


Thank you, I misread that `o' would be different object.
I'll fix it.
----------------------------------------
Bug #8043: Marshal will dump some object with singleton methods
https://bugs.ruby-lang.org/issues/8043#change-37406

Author: marcandre (Marc-Andre Lafortune)
Status: Open
Priority: Normal
Assignee:
Category: core
Target version: current: 2.1.0
ruby -v: r39608


=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
This topic is locked and can not be replied to.