🐞 Fix crash when a cycle action has an empty cycle#1115
Open
bit-saver wants to merge 1 commit into
Open
Conversation
`getNextCycleAction` indexes `currentCycle[0]` when restarting or when no current index is found, but only guarded against a nil `cycle`, not an empty one. A cycle action configured with zero sub-actions therefore traps (EXC_BREAKPOINT) on the empty-array subscript. Guard against an empty cycle and return the action unchanged.
mrkai77
reviewed
Jul 2, 2026
| guard let currentCycle = action.cycle else { | ||
| // An empty cycle has no actions to advance to; bail out instead of indexing | ||
| // into it — the `currentCycle[0]` accesses below would trap on an empty array | ||
| // (EXC_BREAKPOINT crash when a cycle action is configured with no sub-actions). |
Owner
There was a problem hiding this comment.
This feels a bit too verbose. It’s definitely a bug, but I think it’s already fairly clear what !currentCycle.isEmpty is trying to fix here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A cycle action configured with an empty cycle list crashes Loop with
EXC_BREAKPOINT(SIGTRAP) — an out-of-bounds array access.Root cause
LoopManager.getNextCycleActionguardsaction.cycleagainstnilbut not against an empty array, then doescurrentCycle[0]on the cycle-restart path and the "no current index" fallback. An empty cycle →currentCycle[0]traps.Crash (abridged):
EXC_BREAKPOINTinLoopManager.getNextCycleAction→changeAction→openLoop.Fix
Guard against an empty cycle too, returning the action unchanged (there's nothing to advance to).
Testing
Built (Release). A cycle action with zero sub-actions no longer crashes; non-empty cycles are unaffected — the guard only changes the empty case.