Find and fix infinite loops causing application hangs
My application appears to be stuck in an infinite loop. Help me identify and fix it.
**Code section that hangs:**
```{{LANGUAGE}}
{{CODE}}
```
**Programming Language:** {{LANGUAGE}}
**Loop type:** {{LOOP_TYPE}}
**Expected termination condition:** {{EXPECTED_TERMINATION}}
**Inputs that cause the hang:** {{INPUTS}}
Please provide:
1. **Loop Analysis**: Identify why the termination condition is never met
2. **Variable Tracking**: Show how loop variables change (or don't)
3. **Edge Cases**: Identify inputs that cause infinite iteration
4. **Fixed Code**: Provide corrected loop with proper termination
5. **Guard Conditions**: Add safeguards to prevent infinite loops
6. **Timeout Mechanisms**: Suggest timeout patterns if appropriate
7. **Testing Strategy**: Tests to catch infinite loop conditionsOr press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{LANGUAGE][{CODE][{LOOP_TYPE][{EXPECTED_TERMINATION][{INPUTS]