Home Bug Reports

Deeply nested optional sequences lead to serialization error.

jrrayjrray Member J Robert RayOrganization: ImageworksProject: cutlist server
Hello, I have run across a bug using optional values in Ice 3.5.1 (java).

Given a slice definition like this:
module Demo {
    class Inner0 {
        int value;
    };

    sequence<Inner0> Inner0Seq;

    class Inner1 {
        optional(0) Inner0Seq value;
    };

    sequence<Inner1> Inner1Seq;

    class Outer {
        optional(0) Inner1Seq value;
    };
};

Outer#__writeImpl will contain this code fragment:
__os.startSize();
Inner1SeqHelper.write(__os, value);
__os.endSize();

Inner1#__writeImpl will contain this code fragment:
__os.startSize();
Inner0SeqHelper.write(__os, value);
__os.endSize();

During serialization, the inner calls of startSize/endSize will reset BasicStream._sizePos to -1.
When execution reaches the outer endSize, an exception occurs like the following:
java.lang.IndexOutOfBoundsException
        at java.nio.Buffer.checkIndex(Buffer.java:538)
        at java.nio.HeapByteBuffer.putInt(HeapByteBuffer.java:375)
        at IceInternal.BasicStream.rewriteInt(BasicStream.java:1233)
        at IceInternal.BasicStream.endSize(BasicStream.java:726)

I hope you find this information useful.

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    Thanks for the bug report, we will look into fixing this! This problem doesn't affect the C++ implementation but it's an issue for other language mappings.

    Cheers,
    Benoit.
Sign In or Register to comment.