Skip to content

F0059 irq-1

Rule: Interrupt handlers clear exactly the flags they handled.

Code F0059 (stable, never reused)
Id irq-1
Category irq
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded deny bedrock error: Interrupt flags cleared wholesale (all-ones or the read value written back to a W1C register): an event between the read and the clear is lost; clear exactly the flags handled
ui off
egui off
units-strict off
units-paranoid off

Why

A status-register clear that writes all-ones (or writes back the value it just read) instead of exactly the flags the handler is about to act on.

A W1C (write-1-to-clear) register clears every bit written as 1, not just the ones the code cared about; an event flag that sets between the read and the wholesale clear is lost without the handler ever seeing it. On a ring-style peripheral that means a dropped element nothing else notices.

Example

Mcan finding I1/Y6: clearing the whole interrupt status register lost a pending RFxL (Rx FIFO lost message) flag that arrived in the gap between the read and the clear.

How to fix

Clear only the bits the handler is about to act on, computed from what it actually read and handled, not a blanket mask.

How it is checked

src mid: needs the register's field layout to tell "clear everything" from "clear exactly the bits handled"; a literal all-ones write or a write of the just-read value is the pattern to flag.

Source

Ported from embedded_bedrock's firmware check catalogue, IRQ-1 (book/checks.md, detail in book/checks/irq.md). Found on: mcan I1/Y6 (RFxL lost); notion.

Configure

[lints.irq-1]
level = "deny"
reason = "why this project wants it at this level"

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