1994.03.22 08:12 "TIFF 3.3beta002 memory problems", by Glenn Herteg

I have just had occasion to run Purify 2 on my code, which is linked with the TIFF 3.3beta002 library (libtiff.a) on a Sun running SunOS 4.1.3_U1 (Solaris 1.1.1). Rather nicely, it exposed the problem I had introduced into my own code. But it also exposed some problems with the TIFF library, as shown below. Having this happen to your own freshly-minted code makes you a True Believer, and I would now strongly suggest you find some means to apply Purify to the TIFF library!

Anyway, here are the error messages relevant to the TIFF library. Use them as you will to debug the code. The two basic problems are accessing just outside a malloc()ed block, and various memory leaks. Perhaps if you fix these problems, you could drop me a note, because I'm not plugged into the TIFF mailing list.

-- Glenn Herteg
   IA Corporation
   glenn@lia.com

**** Purify'd /home/img/demo/IARS/iars/tools/tempdef/template (pid 11495) ****
Purify (abr): array bounds read:
  * This is occurring while in:
        fillspan [line 275, masks.12, pc=0x73270]
        Fax3Decode2DRow [line 572, module.26, pc=0x75044]
        Fax4Decode [line 50, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_fax4.c, pc=0x77d30]
        TIFFReadEncodedStrip [line 149, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_read.c, pc=0x68820]
        iaImageDecompression [line 442, /home/demo01/users/demo/IARS/iars/lib/preocrlib/preocrlib.c, pc=0x46808]
        load_to_display [line 214, fileselect.c, pc=0x1d630]
  * Reading 1 byte from 0xee5d18 in the heap
    1 byte past end of a malloc'd block at 0xe718a0 of 476280 bytes
  * This block was allocated by malloc called from:
        iaImageDecompression [line 436, /home/demo01/users/demo/IARS/iars/lib/preocrlib/preocrlib.c, pc=0x46784]
        load_to_display [line 214, fileselect.c, pc=0x1d630]
        display_image [line 173, fileselect.c, pc=0x1d4dc]
        XtCallCallbackList [Callback.o, pc=0xef33cb68]
        FileSelectionPB [FileSB.o, pc=0x167148]
        XtCallCallbackList [Callback.o, pc=0xef33cb68]


**** Purify'd /home/img/demo/IARS/iars/tools/tempdef/template (pid 11495) ****
Purify (abw): array bounds write:
  * This is occurring while in:
        fillspan [line 275, masks.12, pc=0x7328c]
        Fax3Decode2DRow [line 572, module.26, pc=0x75044]
        Fax4Decode [line 50, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_fax4.c, pc=0x77d30]
        TIFFReadEncodedStrip [line 149, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_read.c, pc=0x68820]
        iaImageDecompression [line 442, /home/demo01/users/demo/IARS/iars/lib/preocrlib/preocrlib.c, pc=0x46808]
        load_to_display [line 214, fileselect.c, pc=0x1d630]
  * Writing 1 byte to 0xee5d18 in the heap
    1 byte past end of a malloc'd block at 0xe718a0 of 476280 bytes
  * This block was allocated by malloc called from:
        iaImageDecompression [line 436, /home/demo01/users/demo/IARS/iars/lib/preocrlib/preocrlib.c, pc=0x46784]
        load_to_display [line 214, fileselect.c, pc=0x1d630]
        display_image [line 173, fileselect.c, pc=0x1d4dc]
        XtCallCallbackList [Callback.o, pc=0xef33cb68]
        FileSelectionPB [FileSB.o, pc=0x167148]
        XtCallCallbackList [Callback.o, pc=0xef33cb68]


Report (mlk): 245 bytes at 0xe5cb00 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        Fax3SetupState [line 186, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_fax3.c, pc=0x72c20]
        Fax3PreDecode [line 226, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_fax3.c, pc=0x72fb4]
        TIFFStartStrip [line 506, module.28, pc=0x6aca8]
        TIFFFillStrip [line 279, module.13, pc=0x695d0]
        TIFFReadEncodedStrip [line 149, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_read.c, pc=0x687a0]


Report (mlk): 47 bytes at 0xe5be08 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        setString [line 44, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4d5e8]
        TIFFSetField1 [line 242, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4ef90]
        TIFFSetField [line 533, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x51a8c]
        TIFFFetchNormalTag [line 872, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5bb30]
        TIFFReadDirectory [line 424, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x592e8]


Report (mlk): 41 bytes at 0xe5b4b8 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        setString [line 44, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4d5e8]
        TIFFSetField1 [line 310, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4fb24]
        TIFFSetField [line 533, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x51a8c]
        TIFFFetchNormalTag [line 872, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5bb30]
        TIFFReadDirectory [line 424, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x592e8]


Report (mlk): 20 bytes at 0xe5d0f0 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        setString [line 44, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4d5e8]
        TIFFSetField1 [line 248, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4f098]
        TIFFSetField [line 533, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x51a8c]
        TIFFFetchNormalTag [line 872, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5bb30]
        TIFFReadDirectory [line 424, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x592e8]


Report (mlk): 16 bytes at 0xe5c1e8 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        setString [line 44, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4d5e8]
        TIFFSetField1 [line 263, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4f32c]
        TIFFSetField [line 533, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x51a8c]
        TIFFFetchNormalTag [line 872, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5bb30]
        TIFFReadDirectory [line 424, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x592e8]


Report (mlk): 14 bytes at 0xe5b6b8 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        setString [line 44, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4d5e8]
        TIFFSetField1 [line 254, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x4f1a0]
        TIFFSetField [line 533, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dir.c, pc=0x51a8c]
        TIFFFetchNormalTag [line 872, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5bb30]
        TIFFReadDirectory [line 424, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x592e8]


Report (mlk): 4 bytes at 0xe58e48 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        CheckMalloc [line 66, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x572e0]
        TIFFFetchStripThing [line 982, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5c64c]
        TIFFReadDirectory [line 342, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x58d48]
        TIFFClientOpen [line 243, module.6, pc=0x663d8]
        TIFFFdOpen [line 118, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_unix.c, pc=0x6e3bc]


Report (mlk): 4 bytes at 0xe5ba50 lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        CheckMalloc [line 66, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x572e0]
        TIFFFetchStripThing [line 982, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x5c64c]
        TIFFReadDirectory [line 348, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_dirread.c, pc=0x58d8c]
        TIFFClientOpen [line 243, module.6, pc=0x663d8]
        TIFFFdOpen [line 118, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_unix.c, pc=0x6e3bc]


Report (plk): 20480 bytes at 0xee5d58 potentially lost, malloc called from:
        _TIFFmalloc [line 155, module.18, pc=0x6e588]
        TIFFReadBufferSetup [line 480, module.28, pc=0x6a9e4]
        TIFFFillStrip [line 268, module.13, pc=0x69480]
        TIFFReadEncodedStrip [line 149, ~glenn/src/tiff_3.3beta002/v3.3beta002/libtiff/tif_read.c, pc=0x687a0]
        iaImageDecompression [line 442, /home/demo01/users/demo/IARS/iars/lib/preocrlib/preocrlib.c, pc=0x46808]
        load_to_display [line 214, fileselect.c, pc=0x1d630]