nasa / cFE

The Core Flight System (cFS) Core Flight Executive (cFE)
Apache License 2.0
409 stars 201 forks source link

Functional tests may crash if created tasks use floating points #2018

Closed pepepr08 closed 2 years ago

pepepr08 commented 2 years ago

Describe the bug Some functional tests create tasks without using the OS_FP_ENABLED flag. Depending on the platform they are running, the spawned tasks might require floating points to be enabled for the task, otherwise we get an exception.

Code snips These two tests don't use OS_FP_ENABLED to create a task: https://github.com/nasa/cFE/blob/c161cf04fe7c5fd2f2a533ac1d7522b31191eab6/modules/cfe_testcase/src/es_task_test.c#L159-L162

https://github.com/nasa/cFE/blob/c161cf04fe7c5fd2f2a533ac1d7522b31191eab6/modules/cfe_testcase/src/tbl_registration_test.c#L245-L248

Possible fix is to add OS_FP_ENABLED to the function call.

es_task_test.c:

    /* Now do the same but instead of a CFE child task, make an OSAL task that is not associated with a CFE app */
    UtAssert_INT32_EQ(OS_TaskCreate(&OtherTaskId, "NonCfe", TaskFunctionCheckNonAppContext, OSAL_TASK_STACK_ALLOCATE,
                                    4096, OSAL_PRIORITY_C(200), OS_FP_ENABLED),
                      OS_SUCCESS);

tbl_registration_test.c:

    /* Create a separate task to run the tests, to confirm TBL context checks */
    UtAssert_INT32_EQ(OS_TaskCreate(&OtherTaskId, "NonCfe", TestTblNonAppContext, OSAL_TASK_STACK_ALLOCATE, 16384,
                                    OSAL_PRIORITY_C(200), OS_FP_ENABLED),
                      OS_SUCCESS);

System observed on:

Reporter Info Jose F. Martinez Pedraza / NASA GSFC

skliper commented 2 years ago

Sounds to me like you've encountered a platform that requires floating point to be enabled for all tasks, regardless of if the task requires floating point support. In this case for portability it should be added from the PSP, not from cFE.

For VxWorks this was accomplished via OS_BSP_GetResourceTypeConfig and the OS_OBJECT_TYPE_OS_TASK key. Could probably do the same for RTEMS.

skliper commented 2 years ago

Closing this since there's no plan to add the floating point flag for all tasks to fix this bug at the system level. Systems that rely on it can do it from the PSP.