fix: guard against null DMA buffer in Panel_AMOLED_Framebuffer::display()#211
Merged
lovyan03 merged 6 commits intoJul 7, 2026
Merged
Conversation
The previous change to namespace alias broke direct font calls in user scripts. Reverting to ensure users don't need to manually update their font references.
Panel_AMOLED_Framebuffer::display() guards a null _frame_buffer but not the per-line DMA buffers from getDMABuffer(), which return nullptr when the DMA-capable internal heap is transiently exhausted. The subsequent memcpy into a null pointer faults (StoreProhibited). Skip the flush and leave the dirty range intact so the next display() retries once memory frees. A new per-instance _dma_oom flag edge-logs the condition (ESP_LOGW) and its recovery (ESP_LOGI) without per-frame spam. Reproduced and fixed on an M5Stack StopWatch (466x466 CO5300): under memory pressure the small per-line alloc fails while a full-screen buffer is cached, and any transient (e.g. a TLS reconnect) tips it over. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
Hello, @ACEFGI |
lovyan03
pushed a commit
to lovyan03/LovyanGFX
that referenced
this pull request
Jul 7, 2026
Panel_AMOLED_Framebuffer::display() guards a null _frame_buffer but not the per-line DMA buffers from getDMABuffer(), which return nullptr when the DMA-capable internal heap is transiently exhausted. The subsequent memcpy into a null pointer faults (StoreProhibited). Skip the flush and leave the dirty range intact so the next display() retries once memory frees. A new per-instance _dma_oom flag edge-logs the condition (ESP_LOGW) and its recovery (ESP_LOGI) without per-frame spam. Ported from m5stack/M5GFX#211, originally authored by Zac Anderson. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
lovyan03
pushed a commit
that referenced
this pull request
Jul 7, 2026
Follow-up to #211: apply the same null guard to the three getDMABuffer() call sites in writeImage(), via a shared get_dma_buffer_checked() helper with edge-triggered logging.
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.
Problem
Panel_AMOLED_Framebuffer::display()obtains two per-line DMA buffers fromgetDMABuffer()andmemcpys framebuffer data into them each line, but only null-checks_frame_buffer— not the DMA buffers. When the DMA-capable internal heap is exhausted (transient memory pressure),getDMABuffer()returnsnullptr, so the flushmemcpys into a null pointer and the device panics (StoreProhibited, write to0x00000000).Fix
Skip the flush if either DMA buffer is null, leaving the dirty rectangle (
_range_mod) intact so the nextdisplay()retries once memory frees. A per-instance flag edge-logs the condition (ESP_LOGW) and its recovery (ESP_LOGI) without per-frame spam.Minimal repro
heap_caps_get_largest_free_block(MALLOC_CAP_DMA)is below one display line's bytes (panel_width * bytes_per_pixel).Without this patch it panics on the null
memcpy; with it the frame is skipped and redraws once memory is freed.Notes
The same unchecked
getDMABuffer()pattern also appears in thewriteImage*pixel-copy paths; this PR scopes to the framebuffer flush we could reproduce and verify — glad to extend it to a full sweep if you'd prefer.Disclosure on process: this patch was authored by an AI coding agent and reviewed by a human; the bug was discovered and the fix validated on hardware through human + agent collaboration (fault-injection confirming the null path panics without the guard and is safely skipped with it). Happy to open a tracking issue first if that's your preference.