[En-Nut-Discussion] Stack overflow?

Toby Smith s354335 at student.uq.edu.au
Mon Sep 29 05:15:29 CEST 2003


Never mind. I found the problem.

it seems that a 'double' is 64bits on Solaris machines and 32bits on the
avr. So when I ported my code across from solaris to the ethernut I forgot
to change the number of bytes to copy across from my packets to the
automatic variable that stored the result, hence writing over something on
the stack prevent the return statement from completing correctly!

--Toby


On Mon, 29 Sep 2003, Toby Smith wrote:

> I'm running some tests of a small Elvin content-based routing library that
> I've written for the Ethernut.
>
> I've test my library on Solaris and it all seems to work fine.
>
> I've ported it across to the ethernut. I'm using avrgcc as my compiler.
> I've converted all the necessary functions and I have my code running okay
> on the ethernut.
>
> With one exception.
>
> Whenever I receive a certain type of packet, the machine hangs. I'm using
> a rather deeply nested set of function calls to parse this packet, and I
> suspect that I'm overfilling the stack.
>
> I suspect this because I've placed printf's before return statements and
> after the function is called.
>
> For eg:
>
> 	...
> 	printf("returing from function XXX\n");
> 	return;
> 	...
>
> 	...
> 	functionXXX();
> 	printf("returned from function XXX\n");
> 	...
>
> And when this runs on the ethernut, line 'returned from blah' never
> appears for one level of function calls. So it looks like the stack might
> be getting screwed?
>
> I've tried placing my code in another thread and setting the stack size to
> a huge value, but that didn't seem to help.
>
> Any other ideas about what this culd be, or how I could fix it?
>
> --Toby
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo/en-nut-discussion
>



More information about the En-Nut-Discussion mailing list