gnupic: Thread: Re: Segmentation fault ... possible solution


[<<] [<] Page 1 of 1 [>] [>>]
Subject: Re: Segmentation fault ... possible solution
From: Robert Warner ####@####.####
Date: 29 May 2002 03:06:16 -0000
Message-Id: <02052818573205.03555@amdk62300>

Ok, this works ...

//void skip_space(void)
void skip_space( int *prxout)
{
//    int	*prxout = &rxout;		//RXWTest

    while (rxbuff[*prxout] <= ' ')
//    while (rxbuff[10] <= ' ')	//RXWTest
        getch_slip();
}

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: ####@####.####
Subject: Re: Segmentation fault ... possible solution
From: Philip Restuccia ####@####.####
Date: 29 May 2002 13:11:16 -0000
Message-Id: <3CF4CF71.F9F9007C@nortelnetworks.com>

Robert Warner wrote:
> 
> Ok, this works ...
> 
> //void skip_space(void)
> void skip_space( int *prxout)
> {
> //    int       *prxout = &rxout;               //RXWTest

Again, like I stated in my reply to your previous post, this will work
(assuming rxout is global) only because rxout will have been initialized
to 0, as are all global variables that are not otherwise explicitly initialized.

You must NOT assume that local (auto) variables within a function are any particular
value when you enter that function; it depends on what happens to be on the stack at
that point. You should ALWAYS explicitly initialize local variables (if appropriate)
before using them.

	Phil

> 
>     while (rxbuff[*prxout] <= ' ')
> //    while (rxbuff[10] <= ' ') //RXWTest
>         getch_slip();
> }
> 
> 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
####@####.####
Subject: Re: Segmentation fault ... possible solution
From: Scott Dattalo ####@####.####
Date: 29 May 2002 13:37:27 -0000
Message-Id: <Pine.LNX.4.44.0205290625010.22582-100000@ruckus.brouhaha.com>

On Wed, 29 May 2002, Philip Restuccia wrote:

> Robert Warner wrote:
> > 
> > Ok, this works ...
> > 
> > //void skip_space(void)
> > void skip_space( int *prxout)
> > {
> > //    int       *prxout = &rxout;               //RXWTest
> 
> Again, like I stated in my reply to your previous post, this will work
> (assuming rxout is global) only because rxout will have been initialized
> to 0, as are all global variables that are not otherwise explicitly initialized.

Actually, global variables are *not* implicitly initialized to zero by 
SDCC.

Scott

Subject: Re: Segmentation fault ... possible solution
From: Philip Restuccia ####@####.####
Date: 29 May 2002 14:01:44 -0000
Message-Id: <3CF4DCC4.61A98C27@nortelnetworks.com>

Scott Dattalo wrote:
> 
> On Wed, 29 May 2002, Philip Restuccia wrote:
> 
> > Robert Warner wrote:
> > >
> > > Ok, this works ...
> > >
> > > //void skip_space(void)
> > > void skip_space( int *prxout)
> > > {
> > > //    int       *prxout = &rxout;               //RXWTest
> >
> > Again, like I stated in my reply to your previous post, this will work
> > (assuming rxout is global) only because rxout will have been initialized
> > to 0, as are all global variables that are not otherwise explicitly initialized.
> 
> Actually, global variables are *not* implicitly initialized to zero by
> SDCC.


Ah; sorry. I was basing my reply on what is specified by the ANSI C standard.

I guess this accounts for Robert's statement in his first post that it fails, too,
if rxout is defined as a global.

So the problem is apparently just one of using an unitialized variable as an
array index.

	Phil

-- 
Philip Restuccia
Senior Principal Software Engineer
Nortel Networks
####@####.####
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.