Bug 2209 - Assertion failure in OJPEGPostDecode
: Assertion failure in OJPEGPostDecode
Status: RESOLVED FIXED
: libtiff
default
: 3.9.0
: All All
: P2 normal
: ---
Assigned To:
: https://bugzilla.redhat.com/show_bug....
:
:
:
:
  Show dependency treegraph
 
Reported: 2010-06-11 15:08 by
Modified: 2014-12-24 12:29 (History)


Attachments
test2.tif from RedHat bugzilla (320.79 KB, image/tiff)
2010-12-13 21:32, Lee Howard
Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2010-06-11 15:08:41
The test image in https://bugzilla.redhat.com/show_bug.cgi?id=583081 shows yet
another interesting misbehavior:

$ tiff2ps bug583081.tif >/dev/null
...
tiff2ps: tif_ojpeg.c:848: OJPEGPostDecode: Assertion
`sp->libjpeg_session_active!=0' failed.
Aborted    

I tried to fix it like this:

     sp->write_curstrile++;
     if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0)
     {
-        assert(sp->libjpeg_session_active!=0);
-        OJPEGLibjpegSessionAbort(tif);
+        if (sp->libjpeg_session_active!=0)
+            OJPEGLibjpegSessionAbort(tif);
         sp->writeheader_done=0;
     }
 }

That got rid of the assertion crash all right, but instead I get this:

LibJpeg: Improper call to JPEG library in state 0.

So there's something rotten in that state machine, but I don't know the code
well enough to fix it.
------- Comment #1 From 2010-12-13 21:31:56 -------
Taking test2.tif from the RedHat bugzilla, I am testing with CVS HEAD, and I
don't see a crash.  But I do see this:

[root@gollum testme]# tiff2ps -a test2.tif > foo.ps
 -e and -a: Warning: Cannot generate Encapuslated Postscript for multiple
images.
TIFFReadDirectory: Warning, Unknown field with tag 37679 (0x932f) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37680 (0x9330) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37681 (0x9331) encountered.
TIFFSetField: test2.tif: Unknown pseudo-tag 65538.
OJPEGSetupDecode: Warning, Depreciated and troublesome old-style JPEG
compression mode, please convert to new-style JPEG compression and notify
vendor of writing software.
OJPEGDecodeRaw: Fractional scanline not read.
[root@gollum testme]# tiff2pdf -o foo.pdf test2.tif
TIFFReadDirectory: Warning, Unknown field with tag 37679 (0x932f) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37680 (0x9330) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37681 (0x9331) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37679 (0x932f) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37680 (0x9330) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37681 (0x9331) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37679 (0x932f) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37680 (0x9330) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37681 (0x9331) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37679 (0x932f) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37680 (0x9330) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37681 (0x9331) encountered.
tiff2pdf: Missing JPEGProc field in OJPEG image test2.tif.
tiff2pdf: An error occurred creating output PDF file.
[root@gollum testme]# tiffcp -c none test2.tif foo.tif
TIFFReadDirectory: Warning, Unknown field with tag 37679 (0x932f) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37680 (0x9330) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 37681 (0x9331) encountered.
tiffcp: test2.tif: Can't copy/convert subsampled image.
[root@gollum testme]# 

I don't know what to make of this.
------- Comment #2 From 2010-12-13 21:32:47 -------
Created an attachment (id=430) [details]
test2.tif from RedHat bugzilla
------- Comment #3 From 2014-10-02 06:33:40 -------
(In reply to comment #2)
> Created an attachment (id=430) [details] [details]
> test2.tif from RedHat bugzilla

It seems that patch recommended by Tom Lane is already included in libtiff
3.9.4.
------- Comment #4 From 2014-10-07 02:01:28 -------
(In reply to comment #3)
> (In reply to comment #2)
> > Created an attachment (id=430) [details] [details] [details]
> > test2.tif from RedHat bugzilla
> 
> It seems that patch recommended by Tom Lane is already included in libtiff
> 3.9.4.

It is my fault. Similar one patch exists on line 643.
What about to include the patch also to line 846?

regards
Petr Hracek
------- Comment #5 From 2014-10-07 05:19:08 -------
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > Created an attachment (id=430) [details] [details] [details] [details]
> > > test2.tif from RedHat bugzilla
> > 
> > It seems that patch recommended by Tom Lane is already included in libtiff
> > 3.9.4.
> 
> It is my fault. Similar one patch exists on line 643.
> What about to include the patch also to line 846?
> 
> regards
> Petr Hracek

Well I have checked the version with the patch and without them
and difference is only in case of core dump. Library with patch produced row
with "LibJpeg: Improper call to JPEG library in state 0." It means that patch
proposed by Tom Lane does not generated core dump.

Output with not applied patch
[root@rhel66min ~]# tiff2ps test2.tif > /dev/null
TIFFReadDirectory: Warning, test2.tif: unknown field with tag 37679 (0x932f)
encountered.
TIFFReadDirectory: Warning, test2.tif: unknown field with tag 37680 (0x9330)
encountered.
TIFFReadDirectory: Warning, test2.tif: unknown field with tag 37681 (0x9331)
encountered.
TIFFSetField: test2.tif: Unknown pseudo-tag 65538.
OJPEGSetupDecode: Warning, Depreciated and troublesome old-style JPEG
compression mode, please convert to new-style JPEG compression and notify
vendor of writing software.
tiff2ps: tif_ojpeg.c:848: OJPEGPostDecode: Assertion
`sp->libjpeg_session_active!=0' failed.
Aborted (core dumped)
[root@rhel66min ~]# 


Output with applied patch:
[root@rhel66min ~]# tiff2ps test2.tif > /dev/null
TIFFReadDirectory: Warning, test2.tif: unknown field with tag 37679 (0x932f)
encountered.
TIFFReadDirectory: Warning, test2.tif: unknown field with tag 37680 (0x9330)
encountered.
TIFFReadDirectory: Warning, test2.tif: unknown field with tag 37681 (0x9331)
encountered.
TIFFSetField: test2.tif: Unknown pseudo-tag 65538.
OJPEGSetupDecode: Warning, Depreciated and troublesome old-style JPEG
compression mode, please convert to new-style JPEG compression and notify
vendor of writing software.
LibJpeg: Improper call to JPEG library in state 0.
[root@rhel66min ~]#

I think that patch should be enhanced so that last row will not exist.
------- Comment #6 From 2014-12-24 12:29:29 -------
No problem seen with libtiff CVS head