AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
August 2010

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2010.08.22 13:26 "memory error", by Rajat Varma
2010.08.23 13:42 "Re: memory error", by Edward Lam
2010.08.23 15:02 "Re: memory error", by Rajat Varma
2010.08.23 15:15 "Re: memory error", by Scott Ribe
2010.08.23 15:17 "Re: memory error", by Bob Friesenhahn
2010.08.23 15:27 "Re: memory error", by Rajat Varma

2010.08.23 15:02 "Re: memory error", by Rajat Varma

Dear Edward,

Thanks for your response. All my declarations are according to the man page
that you send me. Here is my sample code testwrite.c, from which I generated
the exec testwrite.

#include <stdio.h>
#include <tiffio.h>
#include <stdarg.h>
#include <stdlib.h>

main(argc, argv)
int argc;
char *argv[];

{
                TIFF *in;
                toff_t* bc;
                uint32 rowspstrip,numrows,numcols;
                uint16 bits;

                in = TIFFOpen(argv[1],"r");

                TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bc);
                TIFFGetField(in,TIFFTAG_IMAGELENGTH,&numrows);
                TIFFGetField(in,TIFFTAG_IMAGEWIDTH,&numcols);
                TIFFGetField(in,TIFFTAG_ROWSPERSTRIP,&rowspstrip);
                TIFFGetField(in,TIFFTAG_BITSPERSAMPLE,&bits);

                TIFFClose(in);

}

and I am getting two kind of errors in valgrind. First TIFFOpen is returning
a NULL pointer and second issue is with TIFFGetField. Please see below.

==5751== Syscall param open(filename) points to unaddressable byte(s)
==5751==    at 0x41659BD: open64 (in /lib/libc-2.10.1.so)
==5751==    by 0x4078D6C: TIFFOpen (tif_unix.c:171)
==5751==    by 0x8048594: main (in
/home/rajat/Desktop/spots_program/testwrite)
==5751==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==5751==
==5751==
==5751== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- n
TIFFOpen: (null): Cannot open.
==5751== Invalid read of size 4
==5751==    at 0x404CCEB: TIFFFindFieldInfo (tif_dirinfo.c:753)
==5751==    by 0x404A843: TIFFVGetField (tif_dir.c:971)
==5751==    by 0x404B33A: TIFFGetField (tif_dir.c:957)
==5751==    by 0x80485B4: main (in
/home/rajat/Desktop/spots_program/testwrite)
==5751==  Address 0x284 is not stack'd, malloc'd or (recently) free'd
==5751==
==5751==
==5751== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- n
==5751==
==5751== Process terminating with default action of signal 11 (SIGSEGV)
==5751==  Access not within mapped region at address 0x284
==5751==    at 0x404CCEB: TIFFFindFieldInfo (tif_dirinfo.c:753)
==5751==    by 0x404A843: TIFFVGetField (tif_dir.c:971)
==5751==    by 0x404B33A: TIFFGetField (tif_dir.c:957)
==5751==    by 0x80485B4: main (in
/home/rajat/Desktop/spots_program/testwrite)
==5751==  If you believe this happened as a result of a stack
==5751==  overflow in your program's main thread (unlikely but
==5751==  possible), you can try to increase the size of the
==5751==  main thread stack using the --main-stacksize= flag.
==5751==  The main thread stack size used in this run was 8388608.

Any insights will be highly appreciated.

thanks

rajat

On Mon, Aug 23, 2010 at 9:42 AM, Edward Lam <edward@sidefx.com> wrote:

> On 8/22/2010 9:26 AM, Rajat Varma wrote:
> > ==25472== Invalid read of size 4
> > ==25472==    at 0x404CCEB: TIFFFindFieldInfo (tif_dirinfo.c:753)
> > ==25472==    by 0x404A843: TIFFVGetField (tif_dir.c:971)
> > ==25472==    by 0x404B33A: TIFFGetField (tif_dir.c:957)
> > ==25472==    by 0x8048B3D: main (in
> > /home/rajat/Desktop/spots_program/spotsprogram)
> > ==25472==  Address 0x284 is not stack'd, malloc'd or (recently) free'd
> >
> > Could anyone have an insight as to what kind of problems in the code
> > could give rise to such errors?
>
> My knee jerk reaction is that you're giving TIFFGetField() invalid
> return memory. Make sure you're giving it pointers to the right
> types/sizes according to your field:
>
> http://libtiff.maptools.org/man/TIFFGetField.3tiff.html
>
> Regards,
> -Edward
> _______________________________________________
> Tiff mailing list: Tiff@lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/tiff
> http://www.remotesensing.org/libtiff/
>