# IL2CPP 错误：方法“PlayerController.Update”中因无限递归导致堆栈溢出

- **ID:** `unity/il2cpp-stack-overflow-recursive`
- **领域:** unity
- **类别:** runtime_error
- **错误码:** `IL2CPP-404`
- **验证级别:** ai_generated
- **修复率:** 93%

## 根因

没有基本情况的递归方法调用，或意外的循环引用，导致调用堆栈超过最大深度。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Unity 2022.3 | active | — | — |
| Unity 2023.1 | active | — | — |
| Unity 2023.2 | active | — | — |

## 解决方案

1. ```
   通过添加基本情况或使用迭代方法来识别并修复递归。例如，将递归函数更改为循环。
   ```
2. ```
   添加递归深度计数器，在达到一定调用次数后中断循环。
   ```

## 无效尝试

- **Increase the stack size in Player Settings under 'IL2CPP Code Generation'.** — Increasing stack size only delays the crash; the underlying infinite recursion is not fixed. (80% 失败率)
- **Comment out the entire Update method.** — This removes functionality and does not address the recursion in other methods. (50% 失败率)
