Skip to content

🐞 Fix crash when a cycle action has an empty cycle - #1115

Merged
mrkai77 merged 1 commit into
mrkai77:developfrom
bit-saver:fix/empty-cycle-crash
Aug 7, 2026
Merged

🐞 Fix crash when a cycle action has an empty cycle#1115
mrkai77 merged 1 commit into
mrkai77:developfrom
bit-saver:fix/empty-cycle-crash

Conversation

@bit-saver

Copy link
Copy Markdown
Contributor

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.getNextCycleAction guards action.cycle against nil but not against an empty array, then does currentCycle[0] on the cycle-restart path and the "no current index" fallback. An empty cycle → currentCycle[0] traps.

Crash (abridged): EXC_BREAKPOINT in LoopManager.getNextCycleActionchangeActionopenLoop.

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.

Comment thread Loop/Core/LoopManager.swift Outdated
`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.
@bit-saver
bit-saver force-pushed the fix/empty-cycle-crash branch from 3c8c319 to 5ba949c Compare August 5, 2026 17:19
@mrkai77

mrkai77 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Swiftformat errors are unrelated to this PR; merging! Thanks!

@mrkai77
mrkai77 merged commit 2467291 into mrkai77:develop Aug 7, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants