Skip to content

broken build: uno AVR8JS Test — watchdog .init3 hook missing __attribute__((naked)), ret jumps to garbage #2798

Closed

Description

@zackees

Summary

The uno AVR8JS Test workflow (avr8js_uno_test.yml) is failing on master. Confirmed on CI run https://github.com/FastLED/FastLED/actions/runs/27005282879.

Next group from the README badge sweep after AVR family (#2779/#2780), STM32 GIGA (#2784/#2785), Apollo3 (#2787/#2788), and RP2040 (#2792/#2793).

Failure

The emulator times out after 30s without ever printing Test loop. The captured emulator output is nearly empty:

ERROR: "Test loop" not found in output
This likely indicates the test did not execute properly

The Arduino sketch (examples/Test/Test.ino) is a trivial Serial print:

void setup() {
    Serial.begin(115200);
    Serial.println("Test setup starting");
    delay(100);
}
void loop() {
    EVERY_N_MILLIS(1000) { Serial.println("Test loop!"); }
    delay(1);
}

Neither "Test setup starting" nor "Test loop!" reaches the emulator output — the firmware is crashing before setup() runs.

Regression bisect

CI history for avr8js_uno_test.yml:

Commit Time Conclusion
c2faf92e0e 2026-06-04T05:07Z ✅ success
... (no AVR8JS runs in the gap)
8d1e04e401 2026-06-04T17:56Z ❌ failure (every run since)

The commit chain between green and first-red contains ca09808b5f — "feat(watchdog): real per-platform hardware impls for ALL platforms (#2731 Phase 2) (#2745)", the same PR responsible for the AVR-family compile breakage closed by #2780.

Root cause

In src/platforms/avr/watchdog_avr.impl.hpp:

__attribute__((used, section(".init3")))
inline void fastled_watchdog_init3() {
    sAvrCapturedMcusr = MCUSR;
    MCUSR = 0;
    wdt_disable();
}

The function is not marked __attribute__((naked)). GCC therefore emits a standard function prologue/epilogue ending in ret. But .init3 hooks are not called — they are just code that the linker concatenates inline between .init2 (BSS clear) and .init4 (data copy). When this function returns:

  1. Nothing called it, so there is no return address on the stack.
  2. SP starts at RAMEND; with no prior push, the ret pops two bytes of uninitialized SRAM (or zero, depending on the emulator) and jumps there.
  3. On real hardware that destination is undefined; on avr8js it produces an immediate hang or jump-to-bootloader before setup() ever runs.

That perfectly matches the symptom — the sketch never reaches its first Serial.println.

The in-source comment justifies omitting naked ("naked functions are not intended to hold ordinary C/C++ statements"), but the avr-libc-canonical pattern for clearing MCUSR + disabling the WDT in .init3 uses naked precisely because of the no-ret requirement:

// avr-libc documentation, "WDT_vect" example
void get_mcusr(void) __attribute__((naked, section(".init3"), used));
void get_mcusr(void) {
    mcusr_mirror = MCUSR;
    MCUSR = 0;
    wdt_disable();
}

MCUSR = 0 and wdt_disable() compile to plain SBI/OUT/inline-asm sequences that don't need a stack frame, so naked is safe here.

Fix

Apply __attribute__((naked)) (in addition to used and section(".init3")) to fastled_watchdog_init3(), and drop the inline keyword (which combines awkwardly with naked). Leave the body untouched — GCC will compile the three statements without prologue/epilogue/ret, letting execution fall through to .init4 as .initN chains require.

Re-justify in the comment block: the previous note warning against naked was based on a general concern about register-allocation fragility, but for the three operations this hook actually performs (no stack temps, no calls, no spills) the avr-libc-canonical naked pattern is correct and safe.

Acceptance criteria

  • uno AVR8JS Test goes green on master.
  • The Apollo3, STM32, and RP2040 PRs are not regressed (they don't use the AVR watchdog path).
  • The classic-AVR boards (uno, attiny85, attiny88, attiny4313) still compile cleanly — bash compile uno attiny85 attiny88 attiny4313 all pass.
  • Test sketch reaches setup() and loop() under avr8js.

Out of scope

  • Other remaining red badges: check_esp32_size, check_teensy41_size, unit tests windows. Each will be filed separately. The top-level build aggregate should clear as the underlying workflows go green.

Filed via /loop README badge sweep.

Activity

  1. moved this from Triage to Done in FastLED Trackeron Jun 5, 2026
  2. added a commit that references this issue on Jun 5, 2026
    86fd901
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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions