gnupic: Segmentation fault ... did I bite off more then the current release can do?


Previous by date: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... possible solution, Robert Warner
Next by date: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... possible solution, Philip Restuccia
Previous in thread: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... did I bite off more then the current release can do?, Robert Warner
Next in thread: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... did I bite off more then the current release can do?, Scott Dattalo

Subject: Re: Segmentation fault ... did I bite off more then the current release can do?
From: Philip Restuccia ####@####.####
Date: 29 May 2002 13:10:51 -0000
Message-Id: <3CF4CECD.319A016D@nortelnetworks.com>

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.
> 
> Here is the code:
> ...
> #define RXBUFFLEN  80       // Rx buffer: more than enough for a 32-byte Ping
> ...
> BYTE rxbuff[RXBUFFLEN];     // Receive buffer, I/O ptrs, and 'Rx full' flag
> int rxin, rxout, rxcount;
> ...
> void skip_space(void)
> {
> //    BYTE  rxout;                      //RXWTest failed segmentation fault
> 
>     while (rxbuff[rxout] <= ' ')

If this is *precisely* the way it was originally coded, with the definition
of the local variable 'rxout' uncommented, then the above while test MAY
fail due to rxout not being initialized. Depending on the particular value in
the location on the stack reserved for the local variable rxout at the time
the function is entered, rxout may be within the range 0 <= rxout < 80, making
it a valid index, but may NOT be.

Try initializing it at the point of definition:

	BYTE rxout = 0;

or whatever.

The reason why it works as a global is that globals are initialized to 0 if
they are not explicitly initialized otherwise.

	Phil

> //RXWTest passed no segmentation fault, any const value works
> //    while (rxbuff[0] <= ' ')
>         getch_slip();
> }
> ...
> 
> Note: 'rxout' bing global or local causes this problem.  I tried various
> simple scalar types with no change in the error.
> Note:  This function works (similar, except it uses pointers instead)
> /* Write a byte to the Tx buffer */
> void write_txbuff(int *oset, BYTE *b)
> {
>     txbuff[*oset] = *b;
> }
> 
> I'll attempt to restructure the current problem using pointers to see if this
> fixes the problem.
> 
> Thanks
> Bob
> 
> On Tuesday 28 May 2002 07:57, Scott Dattalo wrote:
> > On Mon, 27 May 2002, Robert Warner wrote:
> > > I'm attempting to build the picweb.c module (with appropriate mods to
> > > code for GNU) from the PICDEM dev board/sw.  After fixing numerous
> > > 'portation' issues/errors (reported by sdcc)  I get a segmentation fault
> > > when I attempt to compile.  Should I not attempt something so large with
> > > this current release of sdcc?  Do you need any more information of the
> > > error?  If so, please specify the information and I'll attempt to get it.
> >
> > In general, if you can boil the source down to the point it exhibits
> > the bug and send a copy to me that'd be great. I also monitor the bug
> > reports sent to SDCC's web page so you can send it there too if you want.
> >
> > If you want to send me a copy of what you got now, I'll run it under my
> > development version of SDCC. Since it's been over a week that I've checked
> > anything in, there are numerous differences between my copy and CVS. (Most
> > notable is automatic function in-lining is almost working.)
> >
> > Scott
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ####@####.####
> > For additional commands, e-mail: ####@####.####
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####

-- 
Philip Restuccia
Senior Principal Software Engineer
Nortel Networks
####@####.####

Previous by date: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... possible solution, Robert Warner
Next by date: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... possible solution, Philip Restuccia
Previous in thread: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... did I bite off more then the current release can do?, Robert Warner
Next in thread: 29 May 2002 13:10:51 -0000 Re: Segmentation fault ... did I bite off more then the current release can do?, Scott Dattalo


Powered by ezmlm-browse 0.20.