Skip to content

Don't try to marshal non-serializable variables#7739

Merged
headius merged 2 commits intojruby:masterfrom
headius:no_marshal_finalizer
Mar 29, 2023
Merged

Don't try to marshal non-serializable variables#7739
headius merged 2 commits intojruby:masterfrom
headius:no_marshal_finalizer

Conversation

@headius
Copy link
Member

@headius headius commented Mar 29, 2023

This fixes #7734 by not confusing the finalizer with marshalable state.

headius added 2 commits March 29, 2023 16:04
This avoids marshaling the __finalizer__ slot and any other
internal state that is not serializable.

Fixes jruby#7734
@headius headius added this to the JRuby 9.4.3.0 milestone Mar 29, 2023
@headius headius merged commit 0b5918c into jruby:master Mar 29, 2023
@headius headius deleted the no_marshal_finalizer branch March 29, 2023 21:33

it "dumps without marshaling any attached finalizer" do
obj = Object.new
ObjectSpace.define_finalizer(obj, &:itself)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this causes:

1)
Marshal.dump with an Object dumps without marshaling any attached finalizer ERROR
ArgumentError: Can't create Binding from C level Proc
/home/eregon/code/rubyspec/core/marshal/dump_spec.rb:464:in `define_finalizer'
/home/eregon/code/rubyspec/core/marshal/dump_spec.rb:464:in `block (3 levels) in <top (required)>'
/home/eregon/code/rubyspec/core/marshal/dump_spec.rb:6:in `<top (required)>'
[| | ==================100%================== | 00:00:00]      0F      1E 

on CRuby 3.0+. Just on 2.7 it seems to work.
I modified the spec a bit to make it work on all CRuby versions: ruby/spec@d44cd79

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Object with finalizer dumps wrong data leading to: load': marshal data too short

2 participants