Pike 8.1.13 (latest git) canonical en-/decoding bug

1 view
Skip to first unread message

Pontus Rodling

unread,
Dec 16, 2019, 5:31:11 AM12/16/19
to Pike mailinglist
Hi Pike devs,

While playing around with some code using 8.1.13 from git I ran into
some really strange behaviour after decoding a mapping that had been
encoded using encode_value_canonic().
The decoded data turned out to be quite different from what had been
originally encoded.

I compiled a new Pike from the latest git commit but the issue was still
occurring, so I set out to narrow down what triggers this and managed to
produce the following test case.

Some observations:
- The value of m->a->foo and the index/key in m->b must be the same.
- m->a->bar must be above a signed 32-bit int.


int main() {
mapping m = ([
"a": ([
"foo": "potato",
"bar": 2147483647 + 1, // max of a signed 32-bit int + 1
]),
"b": ([
"potato": "<-- this should be potato"
]),
]);

write("%O\n", m);
write("================\n");
write("%O\n", decode_value(encode_value_canonic(m)));
}


Which produces the following output:

([ /* 2 elements */
"a": ([ /* 2 elements */
"bar": 2147483648,
"foo": "potato"
]),
"b": ([ /* 1 element */
"potato": "<-- this should be potato"
])
])
================
([ /* 2 elements */
"a": ([ /* 2 elements */
"bar": 2147483648,
"foo": "potato"
]),
"b": ([ /* 1 element */
"foo": "<-- this should be potato"
])
])


Best regards,
Pontus

Henrik Grubbström (Lysator) @ Pike (-) importmöte för mailinglistan

unread,
Dec 18, 2019, 7:43:14 AM12/18/19
to pi...@roxen.com
> Hi Pike devs,
>
> While playing around with some code using 8.1.13 from git I ran into
> some really strange behaviour after decoding a mapping that had been
> encoded using encode_value_canonic().
> The decoded data turned out to be quite different from what had been
> originally encoded.
>
> I compiled a new Pike from the latest git commit but the issue was still
> occurring, so I set out to narrow down what triggers this and managed to
> produce the following test case.
>
> Some observations:
> - The value of m->a->foo and the index/key in m->b must be the same.
> - m->a->bar must be above a signed 32-bit int.

Thanks for the report and test case.

Fixed in Pike master.

/grubba

Reply all
Reply to author
Forward
0 new messages