Skip to content

test(spi): add safety counter guard to ping-pong drain-all loops (#2824) - #2869

Merged
zackees merged 1 commit into
masterfrom
fix/2824-spi-pingpong-polling-drain
Jun 6, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2824-spi-pingpong-polling-drain

Conversation

@zackees

@zackees zackees commented Jun 6, 2026 •

Copy link
Copy Markdown
Member

Closes #2824.

Summary

PR #2843 already shipped the primary fix from this issue (the polling-drain logic bug). This closes out the issue's Additional defense recommendation: add the safety counter + stepStreaming() return-value guard that's already used in the queue-depth test (line 226) to the two drain-all loops that don't yet have it.

Without the guard, a future regression of the same shape would manifest as a 20 s runner-watchdog timeout (the original #2824 symptom). With it, the loop bails after 1000 iterations with a clear FL_CHECK_GT(safety, 0) assertion in milliseconds.

Test cases updated

The 1000-iteration cap leaves generous headroom — a 4 KB-capacity strip of 12345 bytes drains in ~25 ping-pong steps; 8000 bytes polling drains in ~16.

Test plan

  • bash lint --cpp clean
  • bash test spi_pingpong_pipeline_logic — 1/1 passed in 1.73 s (no regression)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Enhanced streaming pipeline tests with safeguards to prevent infinite drain loops and watchdog timeouts, improving test reliability and preventing potential regressions.

Closes #2824.

PR #2843 already fixed the polling-drain logic bug (the encodeIdx-based
branch that produced the infinite loop). This closes out the issue's
"Additional defense" recommendation: add the same `safety` counter +
`stepStreaming()` return-value guard that's already in the queue-depth
test (line 226) to the two drain-all loops that don't yet have it.

Without the guard, a future regression of the same shape would manifest
as a 20 s runner-watchdog timeout (the original #2824 symptom). With it,
the loop bails after 1000 iterations with a clear `FL_CHECK_GT(safety,
0)` assertion in milliseconds.

Affected test cases:
- "Ping-pong - all bytes accounted for after drain" (line 248)
- "Ping-pong - polling path drains all bytes" (line 268, the original
  #2824 hang site)

The 1000-iteration cap leaves generous headroom — a 4 KB-capacity strip
of 12345 bytes drains in ~25 ping-pong steps; 8000 bytes polling drains
in ~16. Any regression that crosses 1000 is the same class of bug that
#2824 caught.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 943c9120-2056-44d4-ab7d-e57105a12098

📥 Commits

Reviewing files that changed from the base of the PR and between f286a5e and 9be4fa7.

📒 Files selected for processing (1)
  • tests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpp

📝 Walkthrough

Walkthrough

Two test cases in the SPI ping-pong pipeline logic test file were updated to add fail-fast safety counters around their streaming-drain completion loops. The counters break if the drain loop stalls and assert that the guard never expired, preventing infinite loops and runner watchdog timeouts.

Changes

Test safety counters for streaming drain loops

Layer / File(s) Summary
Safety counters for streaming drain completion loops
tests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpp
Both "all bytes accounted for after drain" and "polling path drains all bytes" test cases now decrement a safety counter inside their stepStreaming() completion loops, break early if stepStreaming() returns false or safety expires, and assert post-loop that the counter never reached zero. This prevents infinite loops from blocking test execution and allows early detection if a future regression reintroduces an infinite drain condition.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • FastLED/FastLED#2843: Fixes the underlying infinite-loop drain condition in PipelineModel::stepStreaming() that these test safety counters defend against.
  • FastLED/FastLED#2810: Introduced the streaming drain test cases that are now safeguarded with these defensive counters.

Poem

🐰 A loop that drains without a care,
Gets a counter—a safety pair!
If it hangs, we break right through,
No more watchdogs, all tests true! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a safety counter guard to ping-pong drain-all loops to prevent test hangs.
Linked Issues check ✅ Passed The PR implements the 'Additional defense' recommendation from #2824 by adding safety counters and stepStreaming() return-value guards to two drain-all test loops.
Out of Scope Changes check ✅ Passed All changes are confined to the spi_pingpong_pipeline_logic test file and directly address the defensive requirements specified in issue #2824.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2824-spi-pingpong-polling-drain

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
tests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpp

tests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpp:25:10: fatal error: 'fl/stl/cstddef.h' file not found
25 | #include "fl/stl/cstddef.h"
| ^~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/9be4fa7cab2017139d520c7dff59528c909b98c0-9d948ea0bf82c7ec/tmp/clang_command_.tmp.451608.txt
++Contents of '/tmp/coderabbit-infer/9be4fa7cab2017139d520c7dff59528c909b98c0-9d948ea0bf82c7ec/tmp/clang_command_.tmp.451608.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-l

... [truncated 1178 characters] ...

l-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-fdeprecated-macro" "-ferror-limit" "19" "-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf" "-fcxx-exceptions" "-fexceptions"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/9d948ea0bf82c7ec/file.o" "-x" "c++"
"tests/platforms/esp/32/drivers/spi/spi_pingpong_pipeline_logic.cpp"
"-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 6, 2026
@zackees
zackees merged commit 163c5f5 into master Jun 6, 2026
2 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 6, 2026
@zackees
zackees deleted the fix/2824-spi-pingpong-polling-drain branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

test hang: spi_pingpong_pipeline_logic polling-path drains wrong buffer, loops forever (regression in #2810)

1 participant