mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 21:23:57 +08:00
Increase stack space on posix 64bit architectures. (#5447)
When running a simulation with, for example, make posix jmavsim px4 crashed almost 100% reproducable near start up. This turned out to be a stack overflow. On gitter it was suggested that the main reason for this could be stack sizes, as currently used, assume a 32bit pointer size and that doubling the stack size for everything but NuttX would be the Right Thing. This is the solution that I came up with (it makes my core dumps disappear).
This commit is contained in:
@@ -185,6 +185,10 @@ px4_task_t px4_task_spawn_cmd(const char *name, int scheduler, int priority, int
|
|||||||
stack_size = PTHREAD_STACK_MIN;
|
stack_size = PTHREAD_STACK_MIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The stack size is intended for 32-bit architectures; therefore
|
||||||
|
// we often run out of stack space when pointers are larger than 4 bytes.
|
||||||
|
// Double the stack size on posix when we're on a 64-bit architecture.
|
||||||
|
stack_size *= __SIZEOF_POINTER__ >> 2;
|
||||||
rv = pthread_attr_setstacksize(&attr, stack_size);
|
rv = pthread_attr_setstacksize(&attr, stack_size);
|
||||||
|
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user