Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict-type errors/exception when creating TimeBase callback on RTEMS during cFS init #1244

Closed
pepepr08 opened this issue Apr 1, 2022 · 3 comments
Assignees
Milestone

Comments

@pepepr08
Copy link
Contributor

pepepr08 commented Apr 1, 2022

Describe the bug
A memory alignment exception occurs when running with RTEMS on GR740 board when compiling with OMIT_DEPRECATED = true and MISSION_RESOURCEID_MODE = "STRICT"

The exception occurs during cFS init, when starting the TimeBase callback task/thread:
https://github.com/nasa/osal/blob/main/src/os/rtems/src/os-impl-timebase.c#L392-L395

The callback thread OS_TimeBase_CallbackThread function argument is of type osal_id_t.
https://github.com/nasa/osal/blob/main/src/os/shared/src/osapi-timebase.c#L381

RTEMS expects the callback function argument to be of type rtems_task_argument. The conversion from one type to another when starting the task causes the exception.

To Reproduce
Build for rtems5-gr740 with OMIT_DEPRECATED = true and MISSION_RESOURCEID_MODE = "STRICT"
Run cFS on gr740 board

Expected behavior
Successful cFS init.

System observed on:

  • Hardware: GR740
  • OS: RTEMS 5
  • Versions: Draco

Reporter Info
Jose F Martinez Pedraza / GSFC 582

@pepepr08 pepepr08 assigned pepepr08 and unassigned pepepr08 Apr 1, 2022
@pepepr08
Copy link
Contributor Author

pepepr08 commented Apr 6, 2022

Possible solution is to create a helper function like this (with better name and comments):

static void OS_TimeBase_CallbackThread_rtems(rtems_task_argument arg)
{
  osal_id_t id;
  id = OS_ObjectIdFromInteger(arg);
  OS_TimeBase_CallbackThread(id);
}

What do you think @jphickey ?

@skliper skliper added the bug label Jul 20, 2022
@skliper
Copy link
Contributor

skliper commented Jul 20, 2022

@acudmore - any opinions on this one? Should probably get it resolved in Draco.

@jphickey
Copy link
Contributor

Just saw this (sorry I missed the mention from Apr 6) ... but yeah there should just be a wrapper function to deal with the different data type. For example the POSIX implementation already has it, see OS_TimeBasePthreadEntry here:

static void *OS_TimeBasePthreadEntry(void *arg)
{
OS_VoidPtrValueWrapper_t local_arg;
local_arg.opaque_arg = arg;
OS_TimeBase_CallbackThread(local_arg.id);
return NULL;
}

I think rtems_task_argument was an int in 4.11 so a wrapper wasn't strictly needed but its definitely preferable (and more type safe, future proof) to use the entry point wrapper like POSIX has.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants