mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 20:21:04 +00:00
expression_with_stack: added a tweak on TCB stackpointers to avoid false trigger of stack overflow
This commit is contained in:
@@ -21,9 +21,8 @@ void external_stack_function(void)
|
||||
void another_external_stack_function(void)
|
||||
{
|
||||
//We can even use Freertos resources inside of this context.
|
||||
printf("We can even use FreeRTOS resources delaying..., sp=%p\n", get_sp());
|
||||
vTaskDelay(100);
|
||||
printf("Done!, sp=%p\n", get_sp());
|
||||
printf("We can even use FreeRTOS resources... yielding, sp=%p\n", get_sp());
|
||||
taskYIELD();
|
||||
shared_stack_sp = (StackType_t *)get_sp();
|
||||
}
|
||||
|
||||
@@ -31,19 +30,21 @@ TEST_CASE("test printf using shared buffer stack", "[newlib]")
|
||||
{
|
||||
portSTACK_TYPE *shared_stack = malloc(SHARED_STACK_SIZE);
|
||||
|
||||
TEST_ASSERT(shared_stack != NULL);
|
||||
TEST_ASSERT_NOT_NULL(shared_stack);
|
||||
|
||||
SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex();
|
||||
TEST_ASSERT_NOT_NULL(printf_lock);
|
||||
printf("SP: %p\n", get_sp());
|
||||
printf("current task sp: %p\n", get_sp());
|
||||
printf("shared_stack: %p\n", (void *)shared_stack);
|
||||
printf("shared_stack expected top: %p\n", (void *)(shared_stack + SHARED_STACK_SIZE));
|
||||
|
||||
|
||||
esp_execute_shared_stack_function(printf_lock,
|
||||
shared_stack,
|
||||
SHARED_STACK_SIZE,
|
||||
external_stack_function);
|
||||
|
||||
TEST_ASSERT(((shared_stack_sp >= shared_stack_sp) &&
|
||||
TEST_ASSERT(((shared_stack_sp >= shared_stack) &&
|
||||
(shared_stack_sp < (shared_stack + SHARED_STACK_SIZE))));
|
||||
|
||||
esp_execute_shared_stack_function(printf_lock,
|
||||
@@ -51,7 +52,7 @@ TEST_CASE("test printf using shared buffer stack", "[newlib]")
|
||||
SHARED_STACK_SIZE,
|
||||
another_external_stack_function);
|
||||
|
||||
TEST_ASSERT(((shared_stack_sp >= shared_stack_sp) &&
|
||||
TEST_ASSERT(((shared_stack_sp >= shared_stack) &&
|
||||
(shared_stack_sp < (shared_stack + SHARED_STACK_SIZE))));
|
||||
|
||||
vSemaphoreDelete(printf_lock);
|
||||
|
Reference in New Issue
Block a user