www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/17/00:22:58

Date: Sat, 17 Feb 1996 13:14:12 +0800 (GMT+0800)
From: "Orlando A. Andico" <orly AT natalie DOT eee DOT upd DOT edu DOT ph>
To: DJ Delorie <dj AT delorie DOT com>
cc: DJGPP Mailing List <djgpp AT delorie DOT com>
Subject: Re: Segmentation problem in DJGPP v2
Message-ID: <Pine.LNX.3.91.960217131028.207A-100000@natalie.eee.upd.edu.ph>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019