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