Return-Path: <awaresystems.be+caf_=filtered=awaresystems.be@gmail.com>
Delivered-To: filtered@awaresystems.be
Received: from mx4.public.one.com ([10.246.18.24])
	by mail6.local.one.com (Dovecot) with LMTP id /I2ZBpO4tFjqAgAAsyOMew
	for <filtered@awaresystems.be>; Mon, 27 Feb 2017 23:49:52 +0000
X-HalOne-ID: 6dcd2ad4-fd47-11e6-b4a5-b82a72d0454d
Received: from mail-ot0-f169.google.com (unknown [74.125.82.169])
	by mx4.public.one.com (Halon) with ESMTPS
	id 6dcd2ad4-fd47-11e6-b4a5-b82a72d0454d;
	Mon, 27 Feb 2017 23:49:51 +0000 (UTC)
Received: by mail-ot0-f169.google.com with SMTP id k4so62754898otc.0
        for <filtered@awaresystems.be>; Mon, 27 Feb 2017 15:49:51 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-original-authentication-results:x-gm-message-state:delivered-to
         :mime-version:from:date:message-id:to:subject:precedence:list-id
         :list-unsubscribe:list-archive:list-post:list-help:list-subscribe
         :mime-version:sender:errors-to;
        bh=LFnYn1cXDPNeem6wqvVLu88Xi2VR8HvleNxY9KKfzWA=;
        b=gA5aIMJ25b79/VCxPrrxYB5KvDSiUADTMtuzBDJp2JDGdeWV1Pcjw3TSh2i+YWmflf
         qIPhQD+A7BpxdI7mGQBDkvxH+KxHA2vPqelzI5aYriF22K+mTSAagZhByGtEbccxw5+y
         e3SATnqxfpKqNJLlbNH9h/24+AY7s6rfeDhKQsNjJylnSCO/SQF7hKcNZfX05MkfXxpI
         oLLV46j0GJbzpOzL/4dAKQ7ADd9SWmzxRPGAaJ+IOtl4gsQf8R/yPeSQ9AtSstj/VjYK
         +xAffdfgEIPY1uIlc/WT2RxDw9ZHU93Bp0seHDm0U5todG/ZLb6zBQdnQrPFTjZWRt5s
         QC8g==
X-Original-Authentication-Results: mx.google.com;       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org;       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com
X-Gm-Message-State: AMke39loIHIQ46vMTlNoDfigQh22rAlP3/1vTvHmjPvpWxfMZE0ac0Q58mMFFf7NpDSGmm1/ZeTTPrcYf5N6XHvMMR62XBw=
X-Received: by 10.157.28.156 with SMTP id l28mr9420410ota.85.1488239390308;
        Mon, 27 Feb 2017 15:49:50 -0800 (PST)
X-Forwarded-To: filtered@awaresystems.be
X-Forwarded-For: awaresystems.be@gmail.com filtered@awaresystems.be
Delivered-To: awaresystems.be@gmail.com
Received: by 10.202.175.16 with SMTP id y16csp23494oie;
        Mon, 27 Feb 2017 15:49:49 -0800 (PST)
X-Received: by 10.28.209.75 with SMTP id i72mr2498894wmg.31.1488239389397;
        Mon, 27 Feb 2017 15:49:49 -0800 (PST)
Return-Path: <tiff-bounces@lists.maptools.org>
Received: from lists.maptools.org (ks365428.kimsufi.com. [94.23.4.142])
        by mx.google.com with ESMTP id 199si15268158wma.162.2017.02.27.15.49.48;
        Mon, 27 Feb 2017 15:49:49 -0800 (PST)
Received-SPF: neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) client-ip=94.23.4.142;
Authentication-Results: mx.google.com;
       spf=neutral (google.com: 94.23.4.142 is neither permitted nor denied by best guess record for domain of tiff-bounces@lists.maptools.org) smtp.mailfrom=tiff-bounces@lists.maptools.org;
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Received: from [10.1.0.241] (localhost.localdomain [127.0.0.1])
	by lists.maptools.org (Postfix) with ESMTP id 2950A35C028;
	Mon, 27 Feb 2017 18:48:24 -0500 (EST)
Received: from mail-qk0-f175.google.com (mail-qk0-f175.google.com
	[209.85.220.175])
	by lists.maptools.org (Postfix) with ESMTPS id 98AB035C023
	for <tiff@lists.maptools.org>; Mon, 27 Feb 2017 18:48:05 -0500 (EST)
Received: by mail-qk0-f175.google.com with SMTP id n127so123737659qkf.0
	for <tiff@lists.maptools.org>; Mon, 27 Feb 2017 15:48:05 -0800 (PST)
X-Received: by 10.55.212.89 with SMTP id l86mr10860202qki.150.1488239284357;
	Mon, 27 Feb 2017 15:48:04 -0800 (PST)
MIME-Version: 1.0
Received: by 10.140.92.119 with HTTP; Mon, 27 Feb 2017 15:48:04 -0800 (PST)
From: Aaron Boxer <boxerab@gmail.com>
Date: Mon, 27 Feb 2017 18:48:04 -0500
Message-ID: <CAK8GPyA4mun2L-J46rp3+=gsp4idDfLpRdirREfNxVuF2Wu65Q@mail.gmail.com>
To: TIFF mailing list <tiff@lists.maptools.org>
Subject: [Tiff] Possible undefined behaviour in library
X-BeenThere: tiff@lists.maptools.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: TIFF and libtiff discussion <tiff.lists.maptools.org>
List-Unsubscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=unsubscribe>
List-Archive: <http://lists.maptools.org/mailman/private/tiff>
List-Post: <mailto:tiff@lists.maptools.org>
List-Help: <mailto:tiff-request@lists.maptools.org?subject=help>
List-Subscribe: <http://lists.maptools.org/mailman/listinfo/tiff>,
	<mailto:tiff-request@lists.maptools.org?subject=subscribe>
Content-Type: multipart/mixed; boundary="===============1476128004=="
Mime-version: 1.0
Sender: tiff-bounces@lists.maptools.org
Errors-To: tiff-bounces@lists.maptools.org

--===============1476128004==
Content-Type: multipart/alternative; boundary=001a114998f4e293ac05498bb5cc

--001a114998f4e293ac05498bb5cc
Content-Type: text/plain; charset=UTF-8

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

--001a114998f4e293ac05498bb5cc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div><div><div><div><div><div><div><div><div><di=
v><div><div><div><div><div><div>Greetings,<br><br></div>I have what I think=
 to be a case of UB in libtiff. Here is my evidence:<br><br></div>I am on W=
indows, Visual Studio 2015,=C2=A0 working with a mono tiff with alpha chann=
el and ICC profile:<br><br><a href=3D"https://github.com/GrokImageCompressi=
on/grok-test-data/blob/master/input/nonregression/basn4a08.tif" target=3D"_=
blank">https://github.com/<wbr>GrokImageCompression/grok-<wbr>test-data/blo=
b/master/input/<wbr>nonregression/basn4a08.tif</a><br><br></div><div>I exec=
ute the following steps:<br></div><div><br></div>Step 1: lossless compress =
to jpeg 2000 using Grok codec<br></div><br>Step 2: decompress back to TIFF =
using Grok codec<br></div><br>Step 3: compare to original using GraphicsMag=
ick<br></div><br>$ gm compare original.tif round_trip.tif -metric PSNR<br><=
br><br></div>For step 2, if Grok is running in debug mode, then the round t=
rip image is identical<br></div>to the original, as reported by GraphicsMag=
ick.<br><br></div>But, if Grok is running in release mode, then the alpha c=
hannels differ.<br></div>PSNR for alpha channel is around 4.8.<br><br></div=
>Now, you might think this is a bug in Grok.=C2=A0 That&#39;s what I assume=
d at first. <br></div>But then I decompressed the same jp2 file to TIFF wit=
h kdu_expand. And<br></div>that TIFF file also did not match original, AND =
the PSNR on the alpha channel<br></div>was the same as the PSNR from Grok i=
n release mode.<br><br></div>So, what is common between the two binaries? M=
y guess is:=C2=A0 libtiff.<br><br></div>So, what is the best way to trouble=
 shoot this problem?<br><br></div>Thanks,<br></div>Aaron<br><div><div><br><=
br><div><div><div><div><div><div><div><br><div><div><div><div><div><br><div=
><br><br><br></div></div></div></div></div></div></div></div></div></div></=
div></div></div></div></div></div>

--001a114998f4e293ac05498bb5cc--

--===============1476128004==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Tiff mailing list: Tiff@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
--===============1476128004==--
