This is an automated email from the ASF dual-hosted git repository.

utzig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new dcf6ca5  Fix stack sizes and missing stack alignments
dcf6ca5 is described below

commit dcf6ca5b3ac0e45d54e5bdb91c4ed70c06e86404
Author: Fabio Utzig <[email protected]>
AuthorDate: Thu Jan 9 10:45:08 2020 -0300

    Fix stack sizes and missing stack alignments
    
    This fixes issues with memory exhaustion running util/rwlock/selftest
    and kernel/os/selftest due to not using the proper `OS_STACK_ALIGN`
    macros. Because of the lack of control over memory usage when running
    on the sim, this macro multiplies the stack size by 16, to guarantee
    that spare memory is available.
    
    Signed-off-by: Fabio Utzig <[email protected]>
---
 hw/mcu/native/src/hal_timer.c                               | 2 +-
 kernel/os/selftest/syscfg.yml                               | 2 +-
 util/rwlock/selftest/src/testcases/rwlock_test_case_basic.c | 2 +-
 util/taskpool/src/taskpool.c                                | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/mcu/native/src/hal_timer.c b/hw/mcu/native/src/hal_timer.c
index 437d726..098ab8d 100644
--- a/hw/mcu/native/src/hal_timer.c
+++ b/hw/mcu/native/src/hal_timer.c
@@ -26,7 +26,7 @@
  * For native cpu implementation.
  */
 static uint8_t native_timer_task_started;
-#define NATIVE_TIMER_STACK_SIZE   (1024)
+#define NATIVE_TIMER_STACK_SIZE   OS_STACK_ALIGN(1024)
 static os_stack_t native_timer_stack[NATIVE_TIMER_STACK_SIZE];
 static struct os_task native_timer_task_struct;
 static struct os_eventq native_timer_evq;
diff --git a/kernel/os/selftest/syscfg.yml b/kernel/os/selftest/syscfg.yml
index 66c7038..78a736f 100644
--- a/kernel/os/selftest/syscfg.yml
+++ b/kernel/os/selftest/syscfg.yml
@@ -18,4 +18,4 @@
 
 syscfg.vals:
     OS_TIME_DEBUG: 1
-    TASKPOOL_STACK_SIZE: 1536
+    TASKPOOL_STACK_SIZE: 1024
diff --git a/util/rwlock/selftest/src/testcases/rwlock_test_case_basic.c 
b/util/rwlock/selftest/src/testcases/rwlock_test_case_basic.c
index fd6fb4c..32ec1b6 100644
--- a/util/rwlock/selftest/src/testcases/rwlock_test_case_basic.c
+++ b/util/rwlock/selftest/src/testcases/rwlock_test_case_basic.c
@@ -23,7 +23,7 @@
 #define RTCB_READ_TASK_PRIO     10
 #define RTCB_WRITE_TASK_PRIO    11
 
-#define RTCB_STACK_SIZE         1024
+#define RTCB_STACK_SIZE         OS_STACK_ALIGN(1024)
 
 static void rtcb_evcb_read(struct os_event *ev);
 static void rtcb_evcb_write(struct os_event *ev);
diff --git a/util/taskpool/src/taskpool.c b/util/taskpool/src/taskpool.c
index 2a092d6..2a7f1a5 100644
--- a/util/taskpool/src/taskpool.c
+++ b/util/taskpool/src/taskpool.c
@@ -161,7 +161,7 @@ taskpool_alloc(os_task_func_t task_handler, uint8_t prio,
 
     rc = os_task_init(&entry->task, entry->name, taskpool_wrapper,
                       entry, prio, OS_WAIT_FOREVER, entry->stack,
-                      MYNEWT_VAL(TASKPOOL_STACK_SIZE));
+                      OS_STACK_ALIGN(MYNEWT_VAL(TASKPOOL_STACK_SIZE)));
     if (rc != 0) {
         taskpool_lock();
         entry->state = TASKPOOL_STATE_UNUSED;

Reply via email to