-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Environment Information
jruby 9.4.2.0 (3.1.0) 2023-03-21 90d2913 OpenJDK 64-Bit Server VM 11.0.18+10-post-Ubuntu-0ubuntu122.04 on 11.0.18+10-post-Ubuntu-0ubuntu122.04 +jit [x86_64-linux]
Older JRubies are affected equally.
Expected Behavior
This can be done in irb:
a = "" # => ""
ObjectSpace.define_finalizer(a, Kernel.method(:puts)) # => [0, #<Method: Kernel.puts(*)>]
Marshal.load(Marshal.dump(a)) # => ""This expectation is met on MRI and on TruffleRuby.
Actual Behavior
JRuby dumps wrong marshal data when a finalizer is set on the object to be marshaled. It doesn't matter what kind of object it is or which method is set as the finalizer.
a = "" # => ""
ObjectSpace.define_finalizer(a, Kernel.method(:puts)) # => [0, #<Method: Kernel.puts(*)>]
Marshal.load(Marshal.dump(a))
`org/jruby/RubyMarshal.java:149:in `load': marshal data too short (ArgumentError)
from (irb):13:in `evaluate'
from org/jruby/RubyKernel.java:1143:in `eval'
from org/jruby/RubyKernel.java:1586:in `loop'
from org/jruby/RubyKernel.java:1292:in `catch'
from org/jruby/RubyKernel.java:1292:in `catch'
from /home/local/COMCARD-NT/kanis/.rvm/rubies/jruby-9.4.2.0/bin/irb:13:in `<main>'`
# here is the difference:
Marshal.dump(a) # => "\x04\bI\"\x00\a:\x06ET"
Marshal.dump("") # => "\x04\bI\"\x00\x06:\x06ET" Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels