Serious Warning: Possible sw stack corruption, function

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Serious Warning: Possible sw stack corruption, function

Post by medelec35 »

After compiling I have got the following warnings:

Code: Select all

Serious Warning: Possible sw stack corruption, function '__mul_8u_8u' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function '__mul_16s_16u__16' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Although Hardware is running great, I would like to eliminate cause of warming's. I have kept interrupts to a minimum with no delays within etc.
May be a start would be finding out what __mul_8u_8u' & __mul_16s_16u__16 are. I have turned on sw stack and allowing an extra 2 in depth.
Due to the nature of hardware i.e running two EC motors, with taco feed back to keep speeds precise,after reading pot then determine required rpm from look-up table.
I thought two interrupts are conflicting, but after deleting port B interrupt, still same errors. Is is possible to solve this without posting sw, and going by the above warnings please?
Martin

Eric
Posts: 99
Joined: Tue Nov 06, 2007 11:04 pm
Been thanked: 1 time

Re: Serious Warning: Possible sw stack corruption, function

Post by Eric »

Hello Medelec,

I had a similar problem lately: see http://www.matrixmultimedia.com/mmforum ... 968#p16515
It turned out to be a delay problem: 2 macro's using the same delay routine simultaniously.
The solution from Steve ( replacing the delay by a loop ) solved the issue.
Maybe this helps.

Regards,

Eric

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Serious Warning: Possible sw stack corruption, function

Post by medelec35 »

Hiya Eric.
Yes I remember replying to that thread, as it happens just a lucky guess :)
The difference between your error message and my error message is yours use the word 'delay_us'
My error uses the words '__mul_8u_8u' & '__mul_16s_16u__16' and not sure what mul is?
My guess it has something to multiplication of 8 bit and 16 bit integers?
But I can't see how two can conflict since two routines re called separately.......Ah unless there is a risk of while one calculation is being executed, there is a risk of a interrupt taking place and overwriting the same routines which would overwrite original variables because a common temporary storage area for variables is used, since I do have some formula duplications. Still I 'm going to try your method of elimination in attempt to locate the problem area.
Your post has helped, thanks Eric.
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Serious Warning: Possible sw stack corruption, function

Post by medelec35 »

Yay solved it. 8) It appears its just not just delays, or macro routines like LCD commands that can't go in interrupt macros, it is also formula involving 8 or 16bits since calculations probably use same registers. Ben, Steve or Sean, is that correct? Since removing formula eliminated warning. All I did was place a variable set for 1, in place of the formula within interrupt routine. Then in main, created a decision if variable =1 then carry out formula and set variable to 0. But since interrupt could occur quicker then the formula being executed, the counter in the interrupt is inhibited until variable is set to 0. Sorted.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Serious Warning: Possible sw stack corruption, function

Post by Benj »

Hello

Yes it sounds like there is a multiplication routine that is called and may cause corruption if you are inside the function and an interrupt occurrs. It would be good to see what kind of calculation requires these multiplication functions. There may be a way to force Flowcode to compile a bit less efficiently but that gets around this potential problem. Please can you send me a Flowcode file that exibits this behavious and I will look into it.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Serious Warning: Possible sw stack corruption, function

Post by medelec35 »

Sure. Both files sent.
Thanks Ben.
Martin

Post Reply