Skip to content

OS_API_Init() failure due to 0 stack size #525

@adam-stamand

Description

@adam-stamand

Describe the bug
OS_API_Init() fails on generic-linux due to a stack size of 0 being used for the console task.

To Reproduce

  1. Build the provided example using the 'generic-linux' BSP.
  2. Execute the provided example.

Expected behavior
The three test tasks should execute.

Actual behavior
OS_API_Init() fails with the following error message (debug messages enabled):

OS_Posix_InternalTaskCreate_Impl():473:pthread_attr_setstacksize error in OS_TaskCreate: Invalid argument

Code snips
The error occurs on the following call to pthread stack size in OS_Posix_InternalTaskCreate_Impl():

return_code = pthread_attr_setstacksize(&custom_attr, stacksz);

The reason it fails is because the stacksz is set to zero in OS_ConsoleCreate_Impl():

return_code = OS_Posix_InternalTaskCreate_Impl(&consoletask, OS_CONSOLE_TASK_PRIORITY, 0, OS_ConsoleTask_Entry, local_arg.opaque_arg);

System observed on:

  • Hardware: Dell Precision 7540 Laptop
  • OS: WSL2 Ubuntu 18.04.4 LTS
  • Versions: OSAL master

Additional context
This issue is resolved by using a stack size of PTHREAD_STACK_MIN instead of 0:

return_code = OS_Posix_InternalTaskCreate_Impl(&consoletask, OS_CONSOLE_TASK_PRIORITY, PTHREAD_STACK_MIN, OS_ConsoleTask_Entry, local_arg.opaque_arg);

Reporter Info
Adam St. Amand

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions