Stack size and overflows

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm
Location: Finland

Re: Stack size and overflows

Postby kulve » Tue Jan 01, 2013 9:55 pm

I downloaded it but it seems to be Windows only :/

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm
Location: Finland

Re: Stack size and overflows

Postby kulve » Wed Jan 02, 2013 6:06 pm

After clicking around a bit (thanks for the Eclipse setup docs) I got the stack dump with the ChibiOS plugin.

I attached it as a screenshot as I don't know how to get it out as text:
stk-dump01.png
Stack dump
stk-dump01.png (22.85 KiB) Viewed 2589 times


Anyway, to me it looks like there's plenty of free stack available for threads still..? (EDIT: well, I'm not sure how to read those..)

User avatar
Giovanni
Site Admin
Posts: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 744 times
Been thanked: 620 times
Contact:

Re: Stack size and overflows

Postby Giovanni » Wed Jan 02, 2013 6:31 pm

StkUnused is the available stack size in the moment you refreshed the view, apparently there is enough stack size. Note that the stack overflow check is done during context switching only so there could be instances of stack overflows not caught by the OS, for example calling a library function the does not perform any context switching inside.

Just a question, do you have the state checker enabled? Analyzing the trace buffer could also give an hint about the sequence of operations that brought to the overflow.

Without looking at the actual code and performing debug there is not much else I can do. BTW, is that a smart card related application?

Giovanni

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm
Location: Finland

Re: Stack size and overflows

Postby kulve » Wed Jan 02, 2013 7:24 pm

I debugged this a bit further and started to write what actually happens when I realized that I'm calling chBSemWaitS(&sem) to lock a semaphore but I was calling chBSemSignal(&sem) to unlock it, instead of chBSemSignalI(&sem).

No "overflows" after fixing that.

Again just a stupid user error. But as always, thanks for your prompt replies.

mabl
Posts: 417
Joined: Tue Dec 21, 2010 10:19 am
Location: Karlsruhe, Germany
Been thanked: 1 time
Contact:

Re: Stack size and overflows

Postby mabl » Wed Jan 02, 2013 7:45 pm

But this would have been coughed by the state checker if you had enabled debugging, wouldn't it? :twisted:

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm
Location: Finland

Re: Stack size and overflows

Postby kulve » Wed Jan 02, 2013 7:53 pm

At least I have this defined:

Code: Select all

#define CH_DBG_ENABLE_STACK_CHECK       TRUE


I'm assuming that enables the state checker?

User avatar
Giovanni
Site Admin
Posts: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 744 times
Been thanked: 620 times
Contact:

Re: Stack size and overflows

Postby Giovanni » Wed Jan 02, 2013 8:28 pm

Nope, that is the stack check, it is CH_DBG_SYSTEM_STATE_CHECK. Regardless, during development all debug options should be enabled, the system is designed to catch a lot of errors if you allow it to do so.

Giovanni

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm
Location: Finland

Re: Stack size and overflows

Postby kulve » Wed Jan 02, 2013 8:34 pm

Well, I must be blind. I did double check that I have all the defines set that are there in the debug wiki page. But I guess I can't distinguish stack from state :/

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm
Location: Finland

Re: Stack size and overflows

Postby kulve » Fri Jan 04, 2013 6:44 am

Thank you for the state checker. My locking stuff was a mess but now it's mostly fixed. Still something (hopefully small) remaining.


Return to “General Support”

Who is online

Users browsing this forum: Google [Bot] and 4 guests