Jump to content
MarkS

Strcpy - Sw Stack Corruption

Recommended Posts

I get this error:

 

 

Building CASM file

Serious Warning: Possible sw stack corruption, function 'strcpy' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

 

Memory Usage Report

===================

RAM available:1536 bytes, used:790 bytes (51.5%), free:746 bytes (48.5%),

Heap size:746 bytes, Heap max single alloc:127 bytes

ROM available:32768 bytes, used:15428 bytes (47.1%), free:17340 bytes (52.9%)

 

 

I do use 'strcpy' in two tasks and in my interrupt routine. Do I need to write my own 'inline' function for this or is there another way around the problem?

Share this post


Link to post
Share on other sites
Serious Warning: Possible sw stack corruption, function 'strcpy' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

 

I do use 'strcpy' in two tasks and in my interrupt routine. Do I need to write my own 'inline' function for this or is there another way around the problem?

This warning is not one not to dismiss.

Disable interrupts around any calls to strcpy would prevent the corruption, but the warning will still be displayed.

My recommendation is to write you own function to do this job and call that instead of the supplied library version.

 

Regards

Dave

Share this post


Link to post
Share on other sites
Serious Warning: Possible sw stack corruption, function 'strcpy' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)

 

I do use 'strcpy' in two tasks and in my interrupt routine. Do I need to write my own 'inline' function for this or is there another way around the problem?

This warning is not one not to dismiss.

Disable interrupts around any calls to strcpy would prevent the corruption, but the warning will still be displayed.

My recommendation is to write you own function to do this job and call that instead of the supplied library version.

 

Regards

Dave

 

Thanks Dave. I built my own 'INLINE' function for the interrupt handler and the error is gone. I do still call 'strcpy' from two other tasks. Since I'm not getting an error anymore I'm assuming I'm ok now?

thanks,

mark

Share this post


Link to post
Share on other sites

If a task can be switched by a task with higher priority than the running task, both calling 'strcpy', then you may still have problems. Look at disabling interrupts around non-reentrant functions, write reentrant functions or write unique functions to do the same function as you did with the interrupt version of 'strcpy'. Some would same why are you doing 'strcpy' during an interrupt ?

 

You could look at using a semaphore system if you are sharing a resource between tasks.

 

You could try making tasks that use the same resource the same priority level. The RTOS may then wait for a yield point before swiching.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites
If a task can be switched by a task with higher priority than the running task, both calling 'strcpy', then you may still have problems. Look at disabling interrupts around non-reentrant functions, write reentrant functions or write unique functions to do the same function as you did with the interrupt version of 'strcpy'. Some would same why are you doing 'strcpy' during an interrupt ?

 

You could look at using a semaphore system if you are sharing a resource between tasks.

 

You could try making tasks that use the same resource the same priority level. The RTOS may then wait for a yield point before swiching.

 

Cheers

 

Reynard

 

Thanks Reynard. Yes, I've just completely eliminated 'strcpy' from everything. I wrote my own and I'm using it as an 'inline' function to make sure there's no tug-of-war. I do actually run these tasks at the same priority but I don't want to rely on that always being the case.

Share this post


Link to post
Share on other sites
If a task can be switched by a task with higher priority than the running task, both calling 'strcpy', then you may still have problems. Look at disabling interrupts around non-reentrant functions, write reentrant functions or write unique functions to do the same function as you did with the interrupt version of 'strcpy'. Some would same why are you doing 'strcpy' during an interrupt ?
Not true. As the Novo RTOS task switching is co-operative, calling the same function from different NOVO RTOS tasks is not a problem. Linker will warn if it detects a potential issue.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Sorry Dave. Been working with Pre-emptive RTOS's too long.

 

Regards

 

Reynard

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...