fix: 无参数启动时可能把空指针传给 execvp#1704
Conversation
fix llinit error
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: enkilee The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @enkilee. Thanks for your PR. I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Code Review
This pull request refactors argument parsing and execution in ll-init.cpp by passing arguments to run by reference and constructing a null-terminated array for execvp inside the child process. The review feedback recommends preparing this null-terminated array in the parent process before calling fork() to avoid unsafe heap allocations in the child process, ensuring compliance with async-signal-safe standards.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
change 2025 to 2025-2026 in comment
changed by gcs
|
可以 squash 成一个 commit 吗? |
问题根因: parse_args() 在末尾无条件 emplace_back(nullptr),导致:
argc=1(无子命令)时,args = {nullptr},args.empty() 为 false,空参检查永远不生效
args[0] 是 nullptr,传入 execvp(nullptr, ...) 是未定义行为
修复内容(2处改动):
parse_args() (ll-init.cpp:238) — 移除末尾的 args.emplace_back(nullptr)。现在 parse_args 只返回实际的参数指针,args.empty() 能正确检测无参数的情况。
run() (ll-init.cpp:261) — 将参数类型改为 const std::vector<const char *> &(避免不必要的拷贝),并在 fork 后的子进程中构造局部的以 null 结尾的 c_args 数组传给 execvp。这与 delegate_run() 函数(第459行)的模式一致。
修复后的行为:
argc=1 → args 为空 → args.empty() 为 true → 打印 "No arguments provided" 并返回 -1
argc>1 → args 包含实际参数 → run() 中构造 null-terminated 数组 → execvp 正常执行