Stack overruns and max stack size

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
legic_1490776
Level 5
Level 5
25 likes received 10 likes received First like received

I ran out of stack space in my application, but only discovered this by seeing clobbered ram.

1. is there any good way to detect stack overrun (e.g. declaring a variable at the top of the stack region and check for magic number?  If so what is the best way to do this?

2. is there a way I can increase the allocation to the stack?

Thanks!

1 Solution
Anonymous
Not applicable

Hello Idgirod,

1. Is there any good way to detect stack overrun (e.g. declaring a variable at the top of the stack region and check for magic number?  If so what is the best way to do this?

[JT] -See below

// This returns the number of bytes free till the top of RAM at the point of invocation.
UINT32 cfa_mm_MemFreeBytes(void);

// This function returns 0 if a stack overflow was not detected before
// Else it detected an overflow.
UINT8 blecm_DidStackOverflow(void);

2. Is there a way I can increase the allocation to the stack?

[JT] - Increasing the application stack size is not supported.

Let me know if this answers your questions.

JT

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

Hello Idgirod,

1. Is there any good way to detect stack overrun (e.g. declaring a variable at the top of the stack region and check for magic number?  If so what is the best way to do this?

[JT] -See below

// This returns the number of bytes free till the top of RAM at the point of invocation.
UINT32 cfa_mm_MemFreeBytes(void);

// This function returns 0 if a stack overflow was not detected before
// Else it detected an overflow.
UINT8 blecm_DidStackOverflow(void);

2. Is there a way I can increase the allocation to the stack?

[JT] - Increasing the application stack size is not supported.

Let me know if this answers your questions.

JT

0 Likes

Thanks, this does answer my question

0 Likes