From 7313f3f925cfeb0e8d21e604bc9e45d99265b585 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 17 Jul 2018 15:12:44 +1000 Subject: [PATCH 1/2] esp32: Fix race in "TLS Test" where s_task can go out of scope before cleanup finishes Probable cause for CI failures of "LoadStoreError" after this task finishes running. --- components/freertos/test/test_thread_local.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/freertos/test/test_thread_local.c b/components/freertos/test/test_thread_local.c index d5f782b43..912edf966 100644 --- a/components/freertos/test/test_thread_local.c +++ b/components/freertos/test/test_thread_local.c @@ -102,4 +102,6 @@ TEST_CASE("TLS test", "[freertos]") while (running[0] || running[1]) { vTaskDelay(10); } + vTaskDelay(10); /* Make sure idle task can clean up s_task, before it goes out of scope */ } + From b6a7458e147fdf3c6878a47a1e1c3a9ad952d71d Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 17 Jul 2018 15:39:40 +1000 Subject: [PATCH 2/2] esp32 tests: TLS test: use same size stack for static & non-static task Use constant instead of magic number of task priorities. --- components/freertos/test/test_thread_local.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/freertos/test/test_thread_local.c b/components/freertos/test/test_thread_local.c index 912edf966..b80c960fc 100644 --- a/components/freertos/test/test_thread_local.c +++ b/components/freertos/test/test_thread_local.c @@ -87,7 +87,8 @@ static void task_test_tls(void *arg) TEST_CASE("TLS test", "[freertos]") { - static StackType_t s_stack[2048]; + const size_t stack_size = 3072; + StackType_t s_stack[stack_size]; /* with 8KB test task stack (default) this test still has ~3KB headroom */ StaticTask_t s_task; bool running[2] = {true, true}; #if CONFIG_FREERTOS_UNICORE == 0 @@ -96,9 +97,10 @@ TEST_CASE("TLS test", "[freertos]") int other_core = 0; #endif - xTaskCreatePinnedToCore((TaskFunction_t)&task_test_tls, "task_test_tls", 3072, &running[0], 5, NULL, 0); - xTaskCreateStaticPinnedToCore((TaskFunction_t)&task_test_tls, "task_test_tls", sizeof(s_stack), &running[1], - 5, s_stack, &s_task, other_core); + xTaskCreatePinnedToCore((TaskFunction_t)&task_test_tls, "task_test_tls", stack_size, &running[0], + UNITY_FREERTOS_PRIORITY, NULL, 0); + xTaskCreateStaticPinnedToCore((TaskFunction_t)&task_test_tls, "task_test_tls", stack_size, &running[1], + UNITY_FREERTOS_PRIORITY, s_stack, &s_task, other_core); while (running[0] || running[1]) { vTaskDelay(10); }