-
Notifications
You must be signed in to change notification settings - Fork 1.4k
bugfix: correct computation of stack size on Mac Posix port #816
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
bugfix: correct computation of stack size on Mac Posix port #816
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #816 +/- ##
=======================================
Coverage 93.62% 93.62%
=======================================
Files 6 6
Lines 2508 2508
Branches 598 598
=======================================
Hits 2348 2348
Misses 107 107
Partials 53 53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
@tegimeki |
Aligns the stack end to a page boundary before computing its size, since the size depends on both the start and end. The original change which introduced stack alignment (FreeRTOS#674) only worked for cases where the round + trunc operation would wind up within the same area, but would lead to segfaults in other cases. Also adds a typecast to the `mach_vm_round_page()` call, as it is actually a macro which casts to `mach_vm_offset_t` and the result here is used as a `StackType_t` pointer. Tested on ARM64 and Intel MacOS, as well as ARM64 and Intel Linux. The test code included a single-task case, as well as a case with two tasks passing queue messages.
b534a8e to
69e6b75
Compare
|
Kudos, SonarCloud Quality Gate passed! |
Thanks @chinglee-iot, I just pushed a new commit which addresses the formatting issue (unbalanced whitespace) and added another note in the commit message about a (pre-existing, now fixed) compilation warning on Mac OS: This was addressed by casting the result to |
…#816) Aligns the stack end to a page boundary before computing its size, since the size depends on both the start and end. The original change which introduced stack alignment (FreeRTOS#674) only worked for cases where the round + trunc operation would wind up within the same area, but would lead to segfaults in other cases. Also adds a typecast to the `mach_vm_round_page()` call, as it is actually a macro which casts to `mach_vm_offset_t` and the result here is used as a `StackType_t` pointer. Tested on ARM64 and Intel MacOS, as well as ARM64 and Intel Linux. The test code included a single-task case, as well as a case with two tasks passing queue messages.








Description
Aligns the stack end to a page boundary before computing its size, since the size depends on both the start and end.
The original change which introduced stack alignment (#674) only worked for cases where the round + trunc operation would wind up within the same area, but would lead to segfaults in other cases.
Tested on ARM64 and Intel MacOS, as well as ARM64 and Intel Linux. The test cases included a single-task case, as well as a case with two tasks passing queue messages.
Test Steps
Using the Posix port on an M1 Mac, create a task with the default
PTHREAD_STACK_MINor some other "lucky" size. The task can do nothing more than delay in a loop, and you should
get a segfault. If not, a different stack size will cause one. Example backtrace:
Checklist:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.