From 44abedce4cdb1306b6538dba48a6b87084ddd974 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Tue, 26 Jul 2022 22:49:38 +0200 Subject: [PATCH] Changed stack size of codec2 thread when running under linux to prevent stack smashing from codec2_decode. Stack size is set to the default value from the OS --- openrtx/src/core/audio_codec.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openrtx/src/core/audio_codec.c b/openrtx/src/core/audio_codec.c index 449a2d62..3dd436a9 100644 --- a/openrtx/src/core/audio_codec.c +++ b/openrtx/src/core/audio_codec.c @@ -317,16 +317,21 @@ static void *decodeFunc(void *arg) static void startThread(void *(*func) (void *)) { + #ifdef _MIOSIX + // Set stack size of CODEC2 thread to 16kB. pthread_attr_t codecAttr; pthread_attr_init(&codecAttr); pthread_attr_setstacksize(&codecAttr, 16384); - #ifdef _MIOSIX // Set priority of CODEC2 thread to the maximum one, the same of RTX thread. struct sched_param param; param.sched_priority = sched_get_priority_max(0); pthread_attr_setschedparam(&codecAttr, ¶m); + + // Start thread + pthread_create(&codecThread, &codecAttr, func, NULL); + #else + pthread_create(&codecThread, NULL, func, NULL); #endif - pthread_create(&codecThread, &codecAttr, func, NULL); }