From 63b21fdfedac6818b94221558a264fc3daebc2d9 Mon Sep 17 00:00:00 2001 From: Rdzleo Date: Tue, 19 May 2026 13:55:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(rtc):=20volc=5Frtc.c:430=20NULL=20message?= =?UTF-8?q?=20=E5=88=A4=E7=A9=BA,=20idle=20=E5=90=8E=E5=81=B6=E5=8F=91?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E8=B6=85=E6=97=B6=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=20panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 火山 RTC SDK 在 ICE Agent 失败路径下 (如服务端 session idle timeout / NAT 表过期) 会用 message=NULL 调用 _on_global_error 回调, 触发 printf("%s", NULL) → strlen(NULL) → LoadProhibited panic → 设备无故重启。 实测复现条件: - 设备进入 idle 后 10+ 分钟 (无用户活动) - RTC 服务端清理 stale signaling 连接 + NAT 表项过期 - ICE Agent 收到 keepalive failure → state=FAILED - ConnectionService.c 触发 _on_global_error(code, message=NULL) - panic at strlen ROM 0x400556d5 注意: 这是低频偶发, 不是每次 idle 必触发。同样 idle 20 分钟有时不触发 (取决于 SDK 内部 ICE state machine 错误路径走向)。修复成本极低 (一行判空), 收益是消除 该偶发崩溃风险。 修改: components/common/src/volc_rtc.c:430 LOGI("global error %d %s\n", code, message); → LOGI("global error %d %s\n", code, message ? message : "(null)"); 修复后行为: - 服务端 idle 超时仍会触发 _on_global_error - 日志正常打印 "global error (null)" 不再 panic - 设备继续保持 idle, 下次按 BOOT 时 SDK 自动重新 join_room - 软退出+保留 engine 的快速唤醒优化继续生效 (License 节省策略不变) 依赖 commit aeae073: components/common/ 已纳入 git 跟踪 Co-Authored-By: Claude Opus 4.7 (1M context) --- components/common/src/volc_rtc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/common/src/volc_rtc.c b/components/common/src/volc_rtc.c index 9db5bff..1c0520f 100644 --- a/components/common/src/volc_rtc.c +++ b/components/common/src/volc_rtc.c @@ -427,7 +427,10 @@ static void _on_global_error(byte_rtc_engine_t engine, int code, const char* mes rtc->b_channel_joined = false; rtc->b_first_keyframe_received = false; - LOGI("global error %d %s\n", code, message); + // 防御性判空: 火山 RTC SDK 在某些 ICE Agent 失败路径下会用 message=NULL 调用本回调, + // 导致 printf("%s", NULL) → strlen(NULL) → LoadProhibited panic → 设备重启 + // (idle ≥ 10 分钟后服务端 session 超时 / NAT 表过期等场景偶发触发) + LOGI("global error %d %s\n", code, message ? message : "(null)"); LOGI("global error heap_free=%u", (unsigned)heap_caps_get_free_size(MALLOC_CAP_DEFAULT)); msg_data.code = VOLC_MSG_DISCONNECTED; _send_message_2_user(rtc, &msg_data);