Skip to content

F0096 stk-6

Rule: Every stack frame stays within its budget and the deepest call chain within the stack.

Code F0096 (stable, never reused)
Id stk-6
Category stk
Source spirit_level
Fix by hand
Needs the firmware's linked ELF (--elf); skipped without a firmware binary

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded warn bedrock warning: Stack frame over a budget (per function) or a worst-case stack depth over the stack region
ui off
egui off
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
frame integer 2048 bytes of one function's stack frame above which it is reported

Why

A single function's stack frame, or a function's worst-case call-chain depth, exceeding a budget — either a per-function limit or the task/handler's share of the stack region.

This is the general case stk-5 and EXE-11 are specific instances of: without a budget and a way to check it, "does this fit" is only answered by whether it overflowed on hardware (STK-7), which is a much more expensive way to find out.

Example

A 3 KiB stack under flip-link: main calls a function with a 3000-byte frame (over the 2 KiB budget), the path Reset → main → huge needs 3072 bytes, and the HardFault handler stacked on top of that overflows the stack; a recursive function makes the worst case unbounded, which is reported as a candidate.

How to fix

Reduce the deepest call chain's frame sizes (fewer large locals, less by-value state per stk-5), or raise the stack region's budget if the margin was simply too tight.

How it is checked

elf hard: needs the linked ELF's call graph and per-function frame sizes, summed along every path from a task's entry point, including interrupt executors stacking on top of thread mode (EXE-11).

Source

Ported from embedded_bedrock's firmware check catalogue, STK-6 (book/checks.md, detail in book/checks/stk.md). Found on: firmware pack "stack, cycles and flash".

Configure

[lints.stk-6]
level = "deny"
frame = 2048
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(stk-6) <reason> (waivers); the code works there too, as in [lints.F0096].