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

Fix #525, ensure POSIX stack size meets requirements #528

Merged

Conversation

jphickey
Copy link
Contributor

Describe the contribution
The pthread_attr_setstacksize() function stipulates that it may fail if the user-supplied stack size is not at least
PTHREAD_STACK_MIN and also possibly a multiple of page size.

This partially reverts previous PR #508 and adds back rounding up to PTHREAD_STACK_MIN and also adds rounding up to a system page size. However the check for zero stack still remains at the shared level so attempts to create a task with zero
stack will still fail. This allows internal helper threads to be created with a default minimum stack size, however.

Fixes #525

Testing performed
Build and sanity check CFE executing as both normal user and root user.
Execute all unit tests as both normal user and root user.

Expected behavior changes
No failure due to stack size not meeting system requirements.

System(s) tested on
Ubuntu 20.04, running as normal user.
CentOS 8.1 in VM running as root user.

Additional context
This also moves the pthread_attr_setstacksize() call such that it is configured regardless of whether task priorities are enabled nor not (i.e. non root user). The normal user should still be able to configure the stack size even if they lack permission to set scheduling priority.

Also confirmed that by moving the call to pthread_attr_setstacksize() that the original bug report is reproducible in a non-root environment - which is also fixed by this change.

Contributor Info - All information REQUIRED for consideration of pull request
Joseph Hickey, Vantage Systems, Inc.

@jphickey jphickey added the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Jun 29, 2020
@mlouielu
Copy link

mlouielu commented Jun 30, 2020

Should the travis CI also need to run with non-root/root user? (Ah, no need to do that, this PR do pthread_attr_setstacksize regardless of the EnableTaskPriorities

The pthread_attr_setstacksize() function stipulates that it
may fail if the user-supplied stack size is not at least
PTHREAD_STACK_MIN and also possibly a multiple of page size.

This partially reverts previous PR nasa#508 and adds back rounding
up to PTHREAD_STACK_MIN and also adds rounding up to a system
page size.  However the check for zero stack still remains
at the shared level so attempts to create a task with zero
stack will still fail.  This allows internal helper threads
to be created with a default minimum stack size, however.
@skliper
Copy link
Contributor

skliper commented Jun 30, 2020

Should the travis CI also need to run with non-root/root user? (Ah, no need to do that, this PR do pthread_attr_setstacksize regardless of the EnableTaskPriorities

Note I did add nasa/cFS#107 for a CI privileged run for better test coverage.

@astrogeco
Copy link
Contributor

CCB 202-07-01: APPROVED

@astrogeco astrogeco removed the CCB:Ready Pull request is ready for discussion at the Configuration Control Board (CCB) label Jul 2, 2020
@astrogeco astrogeco changed the base branch from master to integration-candidate July 2, 2020 19:23
@astrogeco astrogeco merged commit e52abb8 into nasa:integration-candidate Jul 2, 2020
@skliper skliper added this to the 5.1.0 milestone Aug 21, 2020
@jphickey jphickey deleted the fix-525-pthread-stacksize branch December 3, 2020 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OS_API_Init() failure due to 0 stack size
4 participants