From 08073f6387b80c783ab242c08f6fb03076d11290 Mon Sep 17 00:00:00 2001 From: puterboy Date: Sun, 6 Oct 2024 12:00:18 -0400 Subject: [PATCH] Update signalDecoder.cpp: Fix OOM crash caused by rtl_433_Decoder_Stack to small on Lilygo Lora device (#156) This fixes the crash caused by OOM when low water mark on rtl_433_Decder_Stack drops below 0. (See: https://github.com/1technophile/OpenMQTTGateway/issues/2043) I increased the memory size by 1500 which after running for a week on 2 different Lilygo Lora ESP32 devices leaves the water mark at just over 1KB -- I want to leave a little spare in case there are other sensor configurations and edge cases that would dip further into the stack. I also wrapped the definitions of `rtl_433_Decoder_stack` with `ifndef rtl_433_Decoder_Stack` so that users can easily manually tweak the allocated stack size for their own particular situations. --- src/signalDecoder.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/signalDecoder.cpp b/src/signalDecoder.cpp index f78d8511..6a7b061b 100644 --- a/src/signalDecoder.cpp +++ b/src/signalDecoder.cpp @@ -27,15 +27,17 @@ /*----------------------------- rtl_433_ESP Internals -----------------------------*/ -#if defined(RTL_ANALYZER) || defined(RTL_ANALYZE) -# define rtl_433_Decoder_Stack 60000 -#elif defined(RTL_VERBOSE) || defined(RTL_DEBUG) -# define rtl_433_Decoder_Stack 30000 -#else -# if OOK_MODULATION -# define rtl_433_Decoder_Stack 10000 +#ifndef rtl_433_Decoder_Stack +# if defined(RTL_ANALYZER) || defined(RTL_ANALYZE) +# define rtl_433_Decoder_Stack 60000 +# elif defined(RTL_VERBOSE) || defined(RTL_DEBUG) +# define rtl_433_Decoder_Stack 30000 # else -# define rtl_433_Decoder_Stack 20000 +# if OOK_MODULATION +# define rtl_433_Decoder_Stack 11500 +# else +# define rtl_433_Decoder_Stack 20000 +# endif # endif #endif @@ -575,4 +577,4 @@ void processSignal(pulse_data_t* rtl_pulses) { } else { // logprintfLn(LOG_DEBUG, "processSignal() signal placed on rtl_433_Queue"); } -} \ No newline at end of file +}