[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Marshal::dump error on PowerBook G4

Jamey Cribbs

12/8/2006 7:05:00 PM

Emmett Shear wrote:
> I've written code for a Splay tree in Ruby, and I'm trying to
> serialize it using Marshal::dump.
>
> If I create a tree with 1,000 or 10,000 nodes, Marshal::dump works
> perfectly. When I get up to 100,000 nodes, Marshal::dump causes the
> irb process to die with the error "Illegal Instruction".
>
> Is this a known problem? I tried searching for "Marshal::dump" and
> "Illegal Instruction" it but I didn't turn up anything. I'm on a
> PowerBook G4, running Ruby version 1.8.5 and IRb version 0.9.5. I've
> attached the code for the Splay tree; to reproduce, open irb and run:
>
> require 'splay'
> t = SplayTree.new
> 100000.times {|i| t[i] = i}
> Marshal::dump t

I remember running into something similar when I started working on
Mongoose, which is a ruby rdbms that uses SkipLists for it's indexing.

If I tried to serialize the entire SkipList and it had too many keys, I
would get an error. I ended adding a method that converts the SkipList
to a hash, then feeds the hash to Marshal.dump, and it worked. I also
have another method that loads the Marshalled hash and turns it back
into a SkipList.

Another thing you could do would be to serialize each SplayNode, instead
of the whole tree.

HTH,

Jamey Cribbs

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.

1 Answer

Emmett Shear

12/8/2006 8:11:00 PM

0

On 12/8/06, Jamey Cribbs <jcribbs@netpromi.com> wrote:
> Emmett Shear wrote:
> > I've written code for a Splay tree in Ruby, and I'm trying to
> > serialize it using Marshal::dump.
> >
> > If I create a tree with 1,000 or 10,000 nodes, Marshal::dump works
> > perfectly. When I get up to 100,000 nodes, Marshal::dump causes the
> > irb process to die with the error "Illegal Instruction".
> >
> > Is this a known problem? I tried searching for "Marshal::dump" and
> > "Illegal Instruction" it but I didn't turn up anything. I'm on a
> > PowerBook G4, running Ruby version 1.8.5 and IRb version 0.9.5. I've
> > attached the code for the Splay tree; to reproduce, open irb and run:
> >
> > require 'splay'
> > t = SplayTree.new
> > 100000.times {|i| t[i] = i}
> > Marshal::dump t
>
> I remember running into something similar when I started working on
> Mongoose, which is a ruby rdbms that uses SkipLists for it's indexing.
>
> If I tried to serialize the entire SkipList and it had too many keys, I
> would get an error. I ended adding a method that converts the SkipList
> to a hash, then feeds the hash to Marshal.dump, and it worked. I also
> have another method that loads the Marshalled hash and turns it back
> into a SkipList.
>
> Another thing you could do would be to serialize each SplayNode, instead
> of the whole tree.
>
> HTH,
>
> Jamey Cribbs
>
> Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.
>
>

Thanks, I tried the to_hash workaround and it worked great. It also
reduced the serialized size by a large margin. I'm still slightly
disturbed by Marshal::dump dying so badly, but that definitely solved
the problem.

Emmett