libmir / mir-ion

Ion, JSON, YAML, CSV, CBOR and Msgpack serialization framework
Apache License 2.0
14 stars 6 forks source link

IonSymbolTable fails with very large keys #10

Closed hatf0 closed 2 years ago

hatf0 commented 2 years ago

In the MessagePack deserializer, this test fails:

/// Test map with varying key lengths
@safe pure
version(mir_ion_msgpack_test)
unittest
{
    import mir.ion.ser.msgpack : serializeMsgpack;
    import std.array : replicate;

    ubyte[string] map;
    map["c".replicate(ushort.max + 1)] = 0xFF;

    assert(serializeMsgpack(map).deserializeMsgpack!(typeof(map)) == map);
}

I've narrowed this down to this specific line where we grow the key-space. https://github.com/libmir/mir-ion/blob/b3efeecde5292113c33bb8c701edec2bc61af7ca/source/mir/ion/symbol_table.d#L362 I believe that this if should actually be a while, otherwise we give up on growing the key-space way too early.