[Fix] Issue-567: Out of Memory crashes in Sub-Ghz#569
Open
Lechnio wants to merge 1 commit into
Open
Conversation
Lechnio
requested review from
956MB,
HaxSam,
MatthewKuKanich,
Sil333033 and
WillyJL
as code owners
July 12, 2026 21:54
Lechnio
force-pushed
the
Lechnio/fix/issue-567
branch
from
July 12, 2026 22:54
57c8736 to
d60a7dd
Compare
Lechnio
force-pushed
the
Lechnio/fix/issue-567
branch
from
July 13, 2026 10:19
d60a7dd to
351c63f
Compare
lewisQ17
added a commit
to lewisQ17/Momentum-Firmware
that referenced
this pull request
Jul 19, 2026
…ore RAM") Addresses the SubGHz Out-Of-Memory crashes (Next-Flip#567/Next-Flip#555). Adopts the safe parts of the community PR Next-Flip#569, deliberately EXCLUDING the RX worker stream halving (16->8 KB in subghz_worker.c), which trades RX capture headroom for RAM and needs on-hardware validation on dense signals. * keeloq encoder (lib/subghz/protocols/keeloq.c): allocate the upload buffer lazily and size it to the frame's actual worst case in get_upload(), instead of a fixed 1100 entries (~4.4 KB) held for the encoder's whole life. Frees ~4.4 KB of resident heap and closes a latent overflow for >64-bit variants (furi_check(upindex <= need) bounds it). * Pre-flight heap gating: Flipper's malloc traps on OOM, so a TX/decode started with insufficient (or too fragmented) heap crashes. subghz_txrx_tx_start, raw.c encoder_worker_init and the decode-RAW scene now check memmgr_get_free_heap()/max_free_block() first and fail gracefully — a "Not enough memory" dialog (subghz_i.c) instead of a crash. * file-encoder worker: reserve the RAW_Data line buffer up front so stream_read_line never reallocs (realloc traps on OOM) mid-transmit, and size the playback stream buffer accordingly. * decode-RAW scene: free the worker as soon as playback finishes (was held until exit), on top of the earlier double-free/NULL-guard fixes. * history: raise the free-heap reserve 4->8 KB so a burst of receptions leaves room for a later TX allocation. * transmitter restore path uses the low-level subghz_txrx_tx_start so the silent rolling-counter restore never pops the memory dialog. Verified: clean fbt build. RX worker buffer left at 16 KB (unchanged). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JA9f5sJuwNgBwBNqHWsx2h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's new
Fixed for issue 567
For the reviewer