www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/24/23:57:20

Message-ID: <3632CF43.4F90B4B0@stargate.net>
From: John Kissell <jdk AT stargate DOT net>
X-Mailer: Mozilla 4.02 [en] (Win16; I)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Nested structure problem (maybe)?
References: <36318BAA DOT 91343991 AT stargate DOT net>
Lines: 56
Date: Sun, 25 Oct 1998 00:12:03 -0700
NNTP-Posting-Host: 209.166.130.69
X-Complaints-To: abuse AT sgi DOT net
X-Trace: news.sgi.net 909288528 209.166.130.69 (Sun, 25 Oct 1998 00:08:48 EDT)
NNTP-Posting-Date: Sun, 25 Oct 1998 00:08:48 EDT
Organization: Stargate Industries, LLC.
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

To update all who read or replied...

	Using 'assert' as George Foot suggested, I found that the FILE_TYPE
structure was created as a singlely linked list when the ParseFile()
function expected the structure to be a circular linked list (ie.
last_record->next = NULL   vs.   last_record->next = first_record). Yes,
just a stupid mistake, but a lesson that debuggers wont allways catch
mistakes involving a loop where all iterations but one (the last in this
case) are valid.

Thanks,
John Kissell



 

John Kissell wrote:
> 
> The following is a snippet from a 'C' file that contains many long and
> nested structures. By nested, a main structure 'OBJECT_TYPE *list'
> contains pointers to other structures which contain pointers to lesser
> structures and so on. It compiles and links with no errors *or warnings*
> but I get a SIGSEGV at the 'p=record->text;' line. The rub is that Rhide
> in 'run to cursor' and then debug shows that record->text contains a
> valid string of type char, and in fact, the correct string in the
> correct place for the file that was read in as a test of the code! But
> the program when run unhindered under Rhide stops with a SIGSEGV at the
> 'p = record->text;' line? 


> <snip>
> 
> int ParseFile(OBJECT_TYPE *list)
> { char command[6][2] = {"Z","X","K","I","T","G"},
>        *p,*p1,*p2,tmp[256],tmp2[256];
>   int n,G;
>   double CX=0,CY=0,CI=0,CJ=0,X=0,Y=0,I=0,J=0,arc,start,inc,r;
>   RECORD_TYPE *record;
>   OBJECT_TYPE *graph_win;
> 
>   graph_win=TagSearch(list,GRAPH_WIN); /* in debug this points to the
> correct data */
>   record=graph_win->file->records;     /* this also */
>   vflag.max=vflag.graph=0;             /* and this */
>   view_count=0;                        /* I'll get rid of this global
> eventually */
> 
>   do{
>   X=CX; Y=CY;
>   vflag.park = 0;                       /* this one too */
>   p = record->text; /******* SIGSEGV first flagged here ******/
>   p1 = tmp;         /* Run to cursor at the *end* of this line and then
> debug in Rhide shows that record->text contains exactly what it is
> supposed to?
>

- Raw text -


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