Giter Club home page Giter Club logo

Comments (5)

adamgreen avatar adamgreen commented on July 19, 2024

I have an uncommitted change on my machine from several months ago that attempts to address this issue. If I recall correctly, I found and fixed this issue because it was leading to a global variable being corrupted as the main task was getting set up. I never got to the bottom of all the issues I was hitting with my program at that time so I never got around to pushing up this fix. Here is my diff where I use the task_body instead of the task_id for this check. Maybe you can change the call order to fix it as well.

diff --git a/libraries/rtos/rtx/HAL_CM.c b/libraries/rtos/rtx/HAL_CM.c
index a5a2a9c..acabd65 100644
--- a/libraries/rtos/rtx/HAL_CM.c
+++ b/libraries/rtos/rtx/HAL_CM.c
@@ -52,6 +52,7 @@ BIT dbg_msg;

 /*--------------------------- rt_init_stack ---------------------------------*/

+extern int main (void);
 void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
   /* Prepare TCB and saved context for a first time start of a task. */
   U32 *stk,i,size;
@@ -88,11 +89,11 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
   p_TCB->ptask = task_body;

   /* Set a magic word for checking of stack overflow.
-   For the main thread (ID: 0x01) the stack is in a memory area shared with the
+   For the main thread the stack is in a memory area shared with the
    heap, therefore the last word of the stack is a moving target.
    We want to do stack/heap collision detection instead.
   */
-  if (p_TCB->task_id != 0x01)
+  if (task_body != (FUNCP)main)
       p_TCB->stack[0] = MAGIC_WORD;
 }

from mbed-os.

oresths avatar oresths commented on July 19, 2024

Thanks for answer. I just moved
OS_TID tsk = rt_get_TID ();
task_context->task_id = tsk;
in rt_CMSIS.c before rt_init_context(...).

Though it would be good to see a fix for everyone.

from mbed-os.

0xc0170 avatar 0xc0170 commented on July 19, 2024

Hi,

did you fix it locally? I dont see any change in the rt_CMSIS.c file. Is this bug still present? If not, please close this, otherwise could you send a pull request with a fix for this issue?

Regards,
0xc0170

from mbed-os.

oresths avatar oresths commented on July 19, 2024

I haven’t submitted any fix. I just checked the current version in github and task_id is still used uninitialized.

Both mine and adamgreen’s solution seem to do the trick.
As I am not familiar with mbed coding practices should we change HAL_CM.c or rt_CMSIS.c ?

from mbed-os.

0xc0170 avatar 0xc0170 commented on July 19, 2024

This should be now fixed via #827. Thanks Adam!

from mbed-os.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.