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

osal_core_UT hanging on MCP750/VxWorks #1088

Closed
jphickey opened this issue Jun 25, 2021 · 2 comments · Fixed by #1093 or #1098
Closed

osal_core_UT hanging on MCP750/VxWorks #1088

jphickey opened this issue Jun 25, 2021 · 2 comments · Fixed by #1093 or #1098
Labels
bug unit-test Tickets related to the OSAL unit testing (functional and/or coverage) vxworks
Milestone

Comments

@jphickey
Copy link
Contributor

Describe the bug
When I run osal_core_UT on the MCP750, it seems to run fine until it gets to the OS_TaskCreate test. About 5 tasks into the process of creating OS_MAX_TASKS, output stops, and the test just hangs. Here are the last few lines of output:

[ PASS] 36.004 ut_oscore_task_test.c:138 - OS_TaskCreate(&g_task_ids[3], g_task_names[3], generic_test_task, OSAL_STACKPTR_C(&g_task_stacks[3]), 0, OSAL_PRIORITY_C(UT_TASK_PRIORITY), 0) (-40) == OS_ERR_INVALID_SIZE (-40)
[ PASS] 36.005 ut_oscore_task_test.c:145 - OS_TaskCreate(&g_task_ids[4], g_long_task_name, generic_test_task, OSAL_STACKPTR_C(&g_task_stacks[4]), sizeof(g_task_stacks[4]), OSAL_PRIORITY_C(UT_TASK_PRIORITY), 0) (-13) == OS_ERR_NAME_TOO_LONG (-13)
[ PASS] 36.006 ut_oscore_task_test.c:158 - OS_TaskCreate(&g_task_ids[i], task_name, generic_test_task, OSAL_STACKPTR_C(&g_task_stacks[i]), sizeof(g_task_stacks[i]), OSAL_PRIORITY_C(UT_TASK_PRIORITY), 0) (-14) == OS_ERR_NO_FREE_IDS (-14)
[ INFO] ut_oscore_task_test.c:87:Starting GenericTask: CREATE_TASK0, id: 10001
[ INFO] ut_oscore_task_test.c:87:Starting GenericTask: CREATE_TASK1, id: 10002
[ INFO] ut_oscore_task_test.c:87:Starting GenericTask: CREATE_TASK2, id: 10003
[ INFO] ut_oscore_task_test.c:87:Starting GenericTask: CREATE_TASK3, id: 10004
[ INFO] ut_oscore_task_test.c:87:Starting GenericTask: CREATE_TASK4, id: 10005
[ INFO] ut_oscore_task_test.c:87:Starting GenericTask: CREATE_TASK5,

To Reproduce
Run osal_core_UT on the MCP750 test platform

Expected behavior
Test should pass

System observed on:
MCP750 VxWorks 6.9

Additional context
This test used to pass, so very confusing as to why it seems to be locking up now.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey added the bug label Jun 25, 2021
@jphickey
Copy link
Contributor Author

jphickey commented Jun 25, 2021

Perplexingly, as a debug test I added an OS_TaskDelay() here (inside the for loop):

for (i = 0; i <= OS_MAX_TASKS; i++)
{
memset(task_name, '\0', sizeof(task_name));
UT_os_sprintf(task_name, "CREATE_TASK%d", (int)i);
if (i == OS_MAX_TASKS)
{
UT_RETVAL(OS_TaskCreate(&g_task_ids[i], task_name, generic_test_task, OSAL_STACKPTR_C(&g_task_stacks[i]),
sizeof(g_task_stacks[i]), OSAL_PRIORITY_C(UT_TASK_PRIORITY), 0),
OS_ERR_NO_FREE_IDS);
}
else if (!UT_SETUP(OS_TaskCreate(&g_task_ids[i], task_name, generic_test_task,
OSAL_STACKPTR_C(&g_task_stacks[i]), sizeof(g_task_stacks[i]),
OSAL_PRIORITY_C(UT_TASK_PRIORITY), 0)))
{
break;
}
}

My objective was to see if the test was just getting ahead of the console output... But then the test actually passed.... !!

@jphickey
Copy link
Contributor Author

Actually, I may have realized what is going on, and it turns out maybe the OS_TaskDelay() isn't that bad...

The test creates all these tasks, waits for a short period, then deletes all the tasks.

Each task calls UtPrintf which takes a lock.

If the parent thread doesn't wait long enough and deletes the task while it is still in the midst of the UtPrintf() call, the lock is never released. This is further evidenced by the fact that the 5th message only gets halfway printed then stops - probably the task was deleted at that time.

jphickey added a commit to jphickey/osal that referenced this issue Jun 25, 2021
In the osal_core_UT test, the test task was being deleted while it was
in the midst of a UtPrintf call, which left the BSP mutex in a locked
state, causing deadlock.

Using SEM_DELETE_SAFE attribute avoids task deletion for the mutex
holder, and adding a small delay to the test case makes all the
messages appear as expected (accounts for slow serial console on
test platform).
@jphickey jphickey added the unit-test Tickets related to the OSAL unit testing (functional and/or coverage) label Jun 25, 2021
@skliper skliper added this to the 6.0.0 milestone Jun 28, 2021
astrogeco added a commit that referenced this issue Jul 2, 2021
jphickey pushed a commit to jphickey/osal that referenced this issue Aug 10, 2022
cFE Integration candidate: 2021-01-12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unit-test Tickets related to the OSAL unit testing (functional and/or coverage) vxworks
Projects
None yet
3 participants