已合并
fix(init/ueventd): PID 1 稳定性修复 — waitpid 超时(高-5/6) + ueventd NULL 守卫(高-10) + 单测 #4960
chenjinxiang3创建于 11 天前
fix(init/ueventd): PID 1 稳定性修复 — waitpid 超时(高-5/6) + ueventd NULL 守卫(高-10) + 单测 #4960
已合并
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 chenjinxiang3 的贡献)11 天前 关联了issue:startup_init 稳定性修复:PID 1 冻结/堆破坏/崩溃恢复(高-1~高-11,高-13 + P2 11项)
11 天前 添加了label:waiting_on_author
openharmony_ci
11 天前 评论:
11 天前 评论:
感谢提交 Pull Requests!如果您提交的PR已经开发完毕,请评论 "start build" 触发门禁,更多交互操作,请访问OpenHarmony社区支持命令清单。如果需要调整订阅PR、Issue的变更状态,请访问订阅链接。
Thanks for submitting the pull request. If your Pull Request has already been developed, you can leave a "start build" comment to trigger the gated system. For more commands, please visit OpenHarmony Command List. If you need to change the subscription of a Pull Request or Issue, please visit the link.


11 天前 添加了label:dco检查成功
10 天前 推送 1 个提交:45b75b82-fix(init_context): on sub-init read timeout, restart sub-init to avoid stale-result misalignment
10 天前 推送 1 个提交:45b75b82-fix(init_context): on sub-init read timeout, restart sub-init to avoid stale-result misalignment
此处折叠了112条消息 查看更多
6 天前 关闭了关联的issue
6 天前 合入了pull request,合并节点 SHA:0d03292c5b917befae0cae4383970d7bb37b6920
5 天前 删除了label:waiting_for_review
5 天前 添加了label:merged
openharmony_dcp
2 天前 评论:
2 天前 评论:
你因提交次数过多被限制提交,为保障上库效率、避免资源浪费,请先观看学习视频:https://dcp.openharmony.cn/workbench/video/videoDisplay


背景
init(PID 1)单线程,多处waitpid/strstr无超时/无判空,子进程挂起或 uevent 无 DEVNAME 即冻结/崩溃整机。本 PR 落地其中 3 项"高风险 × 小改动"修复 + 100% 分支覆盖单测。改动(5 文件,+125/−22,单笔 commit)
1. syncexec/DumpFdInfo waitpid 无超时(init_cmds.c)
SyncExecCommand(cfgsyncexec命令)与DumpFdInfo的waitpid(pid,&status,0)无超时,异常子进程挂起即冻结 init(违反 §3.2)。新增WaitPidTimeout(WNOHANG轮询 100ms,超时SIGKILL+收尸,返 -1);syncexec 30s、fd dump 5s。2. appspawn waitpid 无超时(init_service_manager.c)
StopAppSpawnBeforeRebootSIGTERM 后阻塞waitpid(appspawn),D 态/忽略 SIGTERM 则重启冻结。复用WaitPidTimeout(5s+SIGKILL),extern引用init_cmds.c中的共享定义——单一来源,不新增头文件。3. ueventd strstr NULL 解引用(ueventd.c)
HandleRequiredBlockDeviceNodes未判deviceName即strstr,块设备 uevent 不保证带 DEVNAME → NULL 解引用 → ramdiskueventd -b段错误、启动失败。增deviceName != NULL守卫;日志 NULL 打印"(null)"。11 折||链抽为表驱动IsRequiredPartitionName(非 static,行为不变,圈复杂度 ≤10)。测试(在既有文件中新增,100% 分支覆盖)
cmds_unittest.cppWaitPidTimeout_ChildExitsWaitPidTimeout_InvalidPidWaitPidTimeout_TimeoutKillWIFSIGNALED && SIGKILLueventd_event_unittest.cppIsRequiredPartitionName_MatchIsRequiredPartitionName_OtherMatchIsOtherPartitionName→ trueIsRequiredPartitionName_NoMatch验证
ninja -C out/rk3568 init init_unittest→LINK init+LINK init_unittest,0 error,0 warning。单测 ARM 架构,需 rk3568 设备/QEMU 运行。行为变更
约束遵循(AGENTS.md §3)
WNOHANG轮询。realloc(§编码规则)。Signed-off-by: chenjinxiang3 chenjinxiang3@huawei.com