diff --git a/tests/stack_overflow_exception/enc/enc.c b/tests/stack_overflow_exception/enc/enc.c index a62aeaea77..cc89da8ce1 100644 --- a/tests/stack_overflow_exception/enc/enc.c +++ b/tests/stack_overflow_exception/enc/enc.c @@ -53,10 +53,13 @@ oe_result_t enc_initialize_exception_handler() void enc_stack_overflow_exception() { - uint8_t data[8192]; // Over-allocate stack + uint8_t data[1024]; + // Force stack allocation and do the recursive call untill + // the stack overflows asm volatile("leaq %0, %%r8\n\t" - "movw $0, 8191(%%r8)\n\t" + "movw $1, 1023(%%r8)\n\t" + "call enc_stack_overflow_exception\n\t" : : "m"(data) : "r8"); diff --git a/tests/stack_overflow_exception/host/CMakeLists.txt b/tests/stack_overflow_exception/host/CMakeLists.txt index 74ea98b5c0..2517fc145b 100644 --- a/tests/stack_overflow_exception/host/CMakeLists.txt +++ b/tests/stack_overflow_exception/host/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(stack_overflow_exception_host host.c stack_overflow_exception_u.c) string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER) -if (BUILD_TYPE_UPPER STREQUAL "DEBUG") +if (BUILD_TYPE_UPPER STREQUAL "DEBUG" OR USE_DEBUG_MALLOC) target_compile_definitions(stack_overflow_exception_host PRIVATE DEBUG_BUILD) endif () diff --git a/tests/stack_overflow_exception/host/host.c b/tests/stack_overflow_exception/host/host.c index 6312ddbca7..689ad66603 100644 --- a/tests/stack_overflow_exception/host/host.c +++ b/tests/stack_overflow_exception/host/host.c @@ -68,7 +68,7 @@ int main(int argc, const char* argv[]) * therefore an internal buffer on the heap is not freed */ OE_TEST(result == OE_MEMORY_LEAK); #else - OE_TEST(result == OE_OK); + OE_TEST_CODE(result, OE_OK); #endif } else