Page 2 of 2
Re: Stack size and overflows
Posted: Tue Jan 01, 2013 9:55 pm
by kulve
I downloaded it but it seems to be Windows only :/
Re: Stack size and overflows
Posted: Wed Jan 02, 2013 6:06 pm
by kulve
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:

- Stack dump
- stk-dump01.png (22.85 KiB) Viewed 7077 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..)
Re: Stack size and overflows
Posted: Wed Jan 02, 2013 6:31 pm
by Giovanni
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
Re: Stack size and overflows
Posted: Wed Jan 02, 2013 7:24 pm
by kulve
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.
Re: Stack size and overflows
Posted: Wed Jan 02, 2013 7:45 pm
by mabl
But this would have been coughed by the state checker if you had enabled debugging, wouldn't it?

Re: Stack size and overflows
Posted: Wed Jan 02, 2013 7:53 pm
by kulve
At least I have this defined:
Code: Select all
#define CH_DBG_ENABLE_STACK_CHECK TRUE
I'm assuming that enables the state checker?
Re: Stack size and overflows
Posted: Wed Jan 02, 2013 8:28 pm
by Giovanni
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
Re: Stack size and overflows
Posted: Wed Jan 02, 2013 8:34 pm
by kulve
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 :/
Re: Stack size and overflows
Posted: Fri Jan 04, 2013 6:44 am
by kulve
Thank you for the state checker. My locking stuff was a mess but now it's mostly fixed. Still something (hopefully small) remaining.