Bug #7766

Marshal.dump corrupts Hash data when serializing

Added by Tasos Laskos about 1 year ago. Updated about 1 year ago.

[ruby-core:51786]
Status:Closed
Priority:Normal
Assignee:-
Category:-
Target version:2.0.0
ruby -v:ruby 2.0.0dev (2012-11-01 trunk 37411) [x86_64-linux] Backport:

Description

=begin
Marshal.dump seems to corrupt a Hash object during serialization.
The problem is that this does not happen when the affected Hash is serialized by itself but only (as far as I could see) when it's part of a larger object.

Worked on: ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux]

Unfortunately, it can't be reproduced using the attached serialized objects, it only happens when I run one of my system's tests.

I thought that I might be doing something wrong but it works fine on 1.9.3 and also works on 2.0 when I change the serializer to YAML.

Proper object -- YAML
{
            "requests" => 2830,
        "responses" => 2830,
    "time_out_count" => 0,
                "time" => "00:00:17",
                "avg" => 158,
        "sitemap_size" => 776,
    "auditmap_size" => 651,
            "progress" => 100.0,
    "curr_res_time" => 0,
        "curr_res_cnt" => 0,
            "curr_avg" => 0,
    "average_res_time" => 0,
    "max_concurrency" => 20,
        "current_page" => "http://localhost:15407/vulnerable?0_vulnerable_26=stuff26",
                "eta" => "--:--:--",
                "url" => "localhost:57977",
            "status" => "cleanup"
}

Corrupted object - Marshal
{
        "requests" => 2830,
            6154.0 => "time_out_count",
        "responses" => 0,
                0.0 => "average_res_time",
            "time" => 776,
        "00:00:17" => 651,
            "avg" => 100.0,
            350.0 => 0,
    "sitemap_size" => 0,
    "auditmap_size" => 0,
            1301.0 => 0,
        "progress" => 20,
            100.0 => "curr_res_time"
}

I didn't go through the entire repro setup of my system because it's a bit of a hassle but if the info I included here isn't enough I'd be glad to provide any further information you may need.
=end

dump.marshal - Marshal dump in question (567 KB) Tasos Laskos, 02/01/2013 12:57 PM

dump.yaml Magnifier - YAML dump of the same object (947 KB) Tasos Laskos, 02/01/2013 12:57 PM

marshal_bug.rb Magnifier (679 Bytes) Tasos Laskos, 02/01/2013 12:57 PM

History

#1 Updated by Charlie Somerville about 1 year ago

=begin
Does it only corrupt the output, or does it break the actual Hash object passed to it?
=end

#2 Updated by Tasos Laskos about 1 year ago

It only corrupted the output, although a few mins ago I realized I was on the preview and there was an RC1 out.
I just tested RC1 and the problem seems to have been fixed.

Do excuse me and please ignore this issue.

#3 Updated by Vit Ondruch about 1 year ago

  • Status changed from Open to Closed

Also available in: Atom PDF