take-cheeze / mruby-marshal

mruby implementation of cruby marshaling.
12 stars 9 forks source link

I throw the towel #4

Closed asfluido closed 9 years ago

asfluido commented 9 years ago

Take this simple test script:

t={a:[1.0,2,3,2],b:[4,5,1.0,2,2]}

p t
s=Marshal::dump(t)
p Marshal::load(s)

If you run it without the added break at around line 246, it segfaults (spills from float processing into array processing)

If you run it with the break, but leaving the lines around line 544 intact, you get

mruby: /data/code/motri/mruby/mruby-marshal/src/marshal.cpp:413: mrb_value {anonymous}::read_context::marshal(): Assertion `id < (((struct RArray*)((objects).value.p))->len)' failed.

and if you check, the link for the second floating number should be nr. 2, but there are no values in the "objects" array.

If you use the code that's currently in my fork, the resulting object is wrong. Here is the output:

{:a=>[1.0, 2, 3, 2], :b=>[4, 5, 1.0, 2, 2]}
{:a=>[1.0, 2, 3, 2], :b=>[4, 5, [1.0, 2, 3, 2], 2, 2]}

As you see, the reference to the floating number is misinterpreted.

I have tried several things, but I am out of my wits. I hope the author can step in and fix this.