Skip to content

gfx: drawPolygon default MAXN=32 needs ~4.2 KB stack, overflows AVR (Uno) #5287

Closed

Description

@zackees

Follow-up from #5269.

Problem

drawPolygon defaults to MAXN=32. The Exact kernel (drawPolygonCore in src/fl/gfx/primitives.h) then uses about 4.2 KB of stack, which is more than the 2 KB of SRAM on an ATmega328P (Uno). A sketch that calls drawPolygon with the default template arguments on an Uno silently overflows the stack. The examples avoid this by picking a smaller tier (MAXN=8 is about 870 B), but nothing stops a user from doing it.

Proposed fix

Pick one of these:

  • Use a platform-dependent default MAXN: small on !FL_PLATFORM_HAS_LARGE_MEMORY or AVR, 32 elsewhere.
  • Or cut the per-vertex stack footprint.

Also add a compile-time guard or doc note, and verify by compiling for uno with a default-argument call and checking the stack estimate (for example -fstack-usage).

Activity

  1. added
    sanitized
    on Nov 18, 2026
  2. moved this from Triage to Done in FastLED Trackeron Nov 18, 2026
  3. added a commit that references this issue on Nov 18, 2026
    502b454
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions