Skip to content

Commit

Permalink
Update signalDecoder.cpp: Fix OOM crash caused by rtl_433_Decoder_Sta…
Browse files Browse the repository at this point in the history
…ck 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: 1technophile/OpenMQTTGateway#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.
  • Loading branch information
puterboy authored Oct 6, 2024
1 parent d0d10a5 commit 08073f6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/signalDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -575,4 +577,4 @@ void processSignal(pulse_data_t* rtl_pulses) {
} else {
// logprintfLn(LOG_DEBUG, "processSignal() signal placed on rtl_433_Queue");
}
}
}

0 comments on commit 08073f6

Please sign in to comment.