gnupic: Re: Segmentation fault ... other locations of problem and different types of fixes


Previous by date: 30 May 2002 22:18:55 -0000 Re: Segmentation fault ... other locations of problem and different types of fixes, Scott Dattalo
Next by date: 30 May 2002 22:18:55 -0000 Re: Welcome to yo5ofh: Thanks, Alex, David Zethmayr
Previous in thread: 30 May 2002 22:18:55 -0000 Re: Segmentation fault ... other locations of problem and different types of fixes, Scott Dattalo
Next in thread: 30 May 2002 22:18:55 -0000 Re: Segmentation fault ... other locations of problem and different types of fixes, Scott Dattalo

Subject: Re: Segmentation fault ... other locations of problem and different types of fixes
From: ####@####.#### (Linas Vepstas)
Date: 30 May 2002 22:18:55 -0000
Message-Id: <20020530220840.GB8318@backlot.linas.org>

A few weeks ago, when I said that SDCC was usable by "the adeventerous",
if they didn't miond working around odd bugs ... below is exactly what
I meant.

These  types of bugs aren't acceptable for a production compiler used
by beginning programmers, but its very typical of new system bringup. 

(Its even more fun when your cpu chip is brand new too, and hasn't been
debugged yet either).

--linas

On Wed, May 29, 2002 at 05:54:58PM -0400, Robert Warner was heard to remark:
> This may or may not help.  There were 2 additional locations.  However each 
> required a different type of fix to solve it.  Here they are
> (btw, I do this at night ... so I don't get your mails 'til the next day)
> Not to lecture (please do not take offense) ... from my days of teaching 
> ANSI/ISO C for embedded systems ... variables whether initaialized or not can 
> be used as indices for arrays.  C does not check bounds on array access. 
> (Unlike Ada).
> 
> 
> Example of problem #2
> //BOOL get_hexbyte(BYTE *val)
> BOOL get_hexbyte( BYTE *val, int *prxout)
> {
>     BYTE b;
>     BOOL ok=0;
> 
>     *val = 0;
> //    while (isxdigit(rxbuff[rxout]) && get_byte(&b))    //Segmentation Fault
> //    while (isxdigit(rxbuff[*prxout]) && get_byte(&b))   //no help
>     //Fixed with pointer arithmatic
>     while ( isxdigit( *((BYTE *)(rxbuff) + *prxout)) && get_byte(&b))
>     {
>         ok = 1;
>         *val <<= 4;
>         if (b <= '9')
>             *val += b - '0';
>         else
>             *val += (b-'A'+10) & 0xf;
>     }
>     return(ok);
> }
> 
> Example of problem #3
> //BYTE getch_slip(void)
> BYTE getch_slip( int *prxout)
> {
>     BYTE b=0;
> 
>     slipend = rxout>=rxcount;
>     if (!slipend)
>     {
> //        b = rxbuff[rxout++];		          //Segmentation Fault
>         b = *(((BYTE *)rxbuff) + *prxout++);  //Fixed with pointer arithmatic
>         *prxout++;
>         check_byte(b);
>     }
>     return(b);
> }
> 
> 
> Hopefully this additional information helps
> Thanks
> Bob
> 
> 
> 
> On Wednesday 29 May 2002 09:30, Scott Dattalo wrote:
> > On Tue, 28 May 2002, Robert Warner wrote:
> > > Ok,  after several compile/edit sequences I've come up with the
> > > following. It appears an array indexed with a variable causes a problem.
> >
> > And this is undoubtedly a bug in SDCC. I'll look into this right now...
> >
> > Thanks for the report,
> > Scott
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ####@####.####
> > For additional commands, e-mail: ####@####.####
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####

-- 
pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) ####@####.####
PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933

Previous by date: 30 May 2002 22:18:55 -0000 Re: Segmentation fault ... other locations of problem and different types of fixes, Scott Dattalo
Next by date: 30 May 2002 22:18:55 -0000 Re: Welcome to yo5ofh: Thanks, Alex, David Zethmayr
Previous in thread: 30 May 2002 22:18:55 -0000 Re: Segmentation fault ... other locations of problem and different types of fixes, Scott Dattalo
Next in thread: 30 May 2002 22:18:55 -0000 Re: Segmentation fault ... other locations of problem and different types of fixes, Scott Dattalo


Powered by ezmlm-browse 0.20.