Quantcast

Possible undefined behaviour in library

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Possible undefined behaviour in library

Aaron Boxer
Greetings,

I have what I think to be a case of UB in libtiff. Here is my evidence:

I am on Windows, Visual Studio 2015,  working with a mono tiff with alpha channel and ICC profile:

https://github.com/GrokImageCompression/grok-test-data/blob/master/input/nonregression/basn4a08.tif

I execute the following steps:

Step 1: lossless compress to jpeg 2000 using Grok codec

Step 2: decompress back to TIFF using Grok codec

Step 3: compare to original using GraphicsMagick

$ gm compare original.tif round_trip.tif -metric PSNR


For step 2, if Grok is running in debug mode, then the round trip image is identical
to the original, as reported by GraphicsMagick.

But, if Grok is running in release mode, then the alpha channels differ.
PSNR for alpha channel is around 4.8.

Now, you might think this is a bug in Grok.  That's what I assumed at first.
But then I decompressed the same jp2 file to TIFF with kdu_expand. And
that TIFF file also did not match original, AND the PSNR on the alpha channel
was the same as the PSNR from Grok in release mode.

So, what is common between the two binaries? My guess is:  libtiff.

So, what is the best way to trouble shoot this problem?

Thanks,
Aaron








_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Possible undefined behaviour in library

Aaron Boxer
Also, when I use Grok to decompress to PNG in release mode, then the PNG is
identical to the original. So, it all points to libtiff.

On Mon, Feb 27, 2017 at 6:48 PM, Aaron Boxer <[hidden email]> wrote:
Greetings,

I have what I think to be a case of UB in libtiff. Here is my evidence:

I am on Windows, Visual Studio 2015,  working with a mono tiff with alpha channel and ICC profile:

https://github.com/GrokImageCompression/grok-test-data/blob/master/input/nonregression/basn4a08.tif

I execute the following steps:

Step 1: lossless compress to jpeg 2000 using Grok codec

Step 2: decompress back to TIFF using Grok codec

Step 3: compare to original using GraphicsMagick

$ gm compare original.tif round_trip.tif -metric PSNR


For step 2, if Grok is running in debug mode, then the round trip image is identical
to the original, as reported by GraphicsMagick.

But, if Grok is running in release mode, then the alpha channels differ.
PSNR for alpha channel is around 4.8.

Now, you might think this is a bug in Grok.  That's what I assumed at first.
But then I decompressed the same jp2 file to TIFF with kdu_expand. And
that TIFF file also did not match original, AND the PSNR on the alpha channel
was the same as the PSNR from Grok in release mode.

So, what is common between the two binaries? My guess is:  libtiff.

So, what is the best way to trouble shoot this problem?

Thanks,
Aaron









_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Possible undefined behaviour in library

Aaron Boxer
In reply to this post by Aaron Boxer
False alarm, looks like a bug in my code after all, and possibly in lcms library.

Sorry for the noise,
Aaron

On Mon, Feb 27, 2017 at 6:48 PM, Aaron Boxer <[hidden email]> wrote:
Greetings,

I have what I think to be a case of UB in libtiff. Here is my evidence:

I am on Windows, Visual Studio 2015,  working with a mono tiff with alpha channel and ICC profile:

https://github.com/GrokImageCompression/grok-test-data/blob/master/input/nonregression/basn4a08.tif

I execute the following steps:

Step 1: lossless compress to jpeg 2000 using Grok codec

Step 2: decompress back to TIFF using Grok codec

Step 3: compare to original using GraphicsMagick

$ gm compare original.tif round_trip.tif -metric PSNR


For step 2, if Grok is running in debug mode, then the round trip image is identical
to the original, as reported by GraphicsMagick.

But, if Grok is running in release mode, then the alpha channels differ.
PSNR for alpha channel is around 4.8.

Now, you might think this is a bug in Grok.  That's what I assumed at first.
But then I decompressed the same jp2 file to TIFF with kdu_expand. And
that TIFF file also did not match original, AND the PSNR on the alpha channel
was the same as the PSNR from Grok in release mode.

So, what is common between the two binaries? My guess is:  libtiff.

So, what is the best way to trouble shoot this problem?

Thanks,
Aaron









_______________________________________________
Tiff mailing list: [hidden email]
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Loading...