Mail Archives: djgpp/1996/02/17/00:22:58
On Fri, 16 Feb 1996, DJ Delorie wrote:
>
> Have you tried compiling with "gcc -g" and debugging with "gdb susan"
> ? You can type "where" after it stops and find out where it's dying.
>
I've cutout the code where the program is dying. Here it is:
----------------------------------------------------
/* {{{ int getint(fp) derived from XV */
int getint(fd)
FILE *fd;
{
int c, i;
char dummy[10000];
c = getc(fd); <--- program dies here
^^^^^^^^^^^^^^^^^
while (1) /* find next integer */
{
if (c=='#') /* if we're at a comment, read to end of line */
fgets(dummy,9000,fd);
if (c==EOF)
exit_error("Image %s not binary PGM.\n","is");
if (c>='0' && c<='9')
break; /* found what we were looking for */
c = getc(fd);
}
----------------------------------------------------
The problem isn't due to an invalid fopen() somewhere being passed to the
program. It seems so unlikely that there's a bug in getc(). I think the
problem is with the declaration
char dummy[10000];
since this is a local variable, it gets allocated off the stack, right?
could this be sufficient to cause a SIGSEGV?
Thanks,
Orly
PS please respond to oandico AT eee DOT upd DOT edu DOT ph
- Raw text -