libimagequant icon indicating copy to clipboard operation
libimagequant copied to clipboard

Test failure on big-endian

Open radarhere opened this issue 3 years ago • 1 comments

Hi. Yes, I created #75 about ppc64le, it was fixed in libimagequant 4.0, and now I'm back again.

I've found a failure with libimagequant 4.0 that occurs on s390x, but not ppc64le, arm64v8 or amd64. The difference is presumably that s390x is big-endian.

Rather than trying to figure out exactly what is happening in libimagequant terms during my test, I've run the tests that you suggested.

They give a failure at the last step -

c_test-1911acffb39972b4: test.c:84: test_histogram: Assertion `LIQ_OK == err' failed.
error: test failed, to rerun pass '-p c_test --lib'

Let me know if there is anything further I can do to assist.

radarhere avatar Feb 12 '22 21:02 radarhere

Thanks. Failure due to endianness seems likely.

kornelski avatar Feb 14 '22 17:02 kornelski

I've reviewed the code for endianness problems, and haven't found any.

I've tried reproducing the problem in the s390x docker image, and got a bizarre unrelated failure. It looks like a miscompilation in GCC, or perhaps a bug in qemu.

        liq_error remap_error = liq_image_quantize(options->fixed_palette_image ? options->fixed_palette_image : input_image, liq, &remap);

        fprintf(stderr, "result is %d == %d\n", LIQ_OK, remap_error);

        if (LIQ_OK == remap_error) {
          // NOT TAKEN!!!
        } else {
           fprintf("fail %d\n", remap_error);
        }

This code prints:

result is 0 == 0 fail 0

So it's a bit difficult to support a platform where 0 is not equal to 0 :)

kornelski avatar Mar 16 '23 14:03 kornelski