jsonnet icon indicating copy to clipboard operation
jsonnet copied to clipboard

Left-shift of negative values is undefined [OSS-Fuzz issue 419059440]

Open oss-fuzz-robot opened this issue 6 months ago • 2 comments

OSS-Fuzz has found a bug in this project. Please see https://oss-fuzz.com/testcase?key=6323798310256640 for details and reproducers.

This issue is mirrored from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=419059440 and will auto-close if the status changes there.

If you have trouble accessing this report, please file an issue at https://github.com/google/oss-fuzz/issues/new.

oss-fuzz-robot avatar May 20 '25 20:05 oss-fuzz-robot

Left-shift of negative values is undefined. So, bitshift operations still need improvement.

johnbartholomew avatar May 22 '25 12:05 johnbartholomew

Unfortunately, the jsonnet specification is lacking here. It just says:

Bitwise: Operators <<, >>, &, ^, | and ~ first convert their operands to signed 64 bit integers, then perform the operations in a standard way, then convert back to IEEE double precision floating point. In shift operations <<, >>, the right hand value modulo 64 is interpreted as the shift count. Shifting with a negative shift count raises an error.

But "then perform the operations in a standard way" is... highly ambiguous, since it doesn't indicate what standard might be followed here, and since some obvious choices of standards (eg, C++, at least prior to C++20) leave some of these behaviours incompletely defined.

johnbartholomew avatar May 22 '25 12:05 johnbartholomew