Fix #525, ensure POSIX stack size meets requirements #528
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the contribution
The
pthread_attr_setstacksize()
function stipulates that it may fail if the user-supplied stack size is not at leastPTHREAD_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 zerostack 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.