From d78ffbd1cb067e88f9da2fb1566f859f9fbf8880 Mon Sep 17 00:00:00 2001 From: Afonso Oliveira Date: Mon, 12 Oct 2026 13:44:23 +0100 Subject: [PATCH] fix(nuttx): scale task stack sizes with the pointer size Module stack sizes are tuned for 32-bit targets. The POSIX task spawn and the work queues already pass them through PX4_STACK_ADJUSTED(), which doubles them when pointers are 64-bit; px4_task_spawn_cmd() on NuttX did not, so a 64-bit NuttX target overflows stacks such as the SIH simulator's. On 32-bit targets PX4_STACK_ADJUSTED() leaves the size unchanged. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Afonso Oliveira --- platforms/nuttx/src/px4/common/tasks.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/platforms/nuttx/src/px4/common/tasks.cpp b/platforms/nuttx/src/px4/common/tasks.cpp index 0b863c8cbbc..c352e30dcea 100644 --- a/platforms/nuttx/src/px4/common/tasks.cpp +++ b/platforms/nuttx/src/px4/common/tasks.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -71,9 +72,9 @@ int px4_task_spawn_cmd(const char *name, int scheduler, int priority, int stack_ #if !defined(__KERNEL__) /* create the task */ - int pid = task_create(name, priority, stack_size, entry, argv); + int pid = task_create(name, priority, PX4_STACK_ADJUSTED(stack_size), entry, argv); #else - int pid = kthread_create(name, priority, stack_size, entry, argv); + int pid = kthread_create(name, priority, PX4_STACK_ADJUSTED(stack_size), entry, argv); #endif if (pid > 0) {