Bug in run_cmd_with_timeout means you always get an error about `ls -d` timing out

未关闭 适合新手
#225 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python
领域
cli

调研方向

从 src/dvsim/cli/run.py 和 src/dvsim/utils/subprocess.py 中的 run_cmd_with_timeout 实现开始,跟踪 SCRATCH_ROOT 路径和引用的 poll 检查。使用 ls -d 命令验证行为,并确认成功退出不再被报告为超时。

由索引模型根据 Issue 内容生成。

描述

If the SCRATCH_ROOT env var is set you hit this code: https://github.com/lowRISC/dvsim/blob/0f1346640562da32bc399530b309487e9e1df832/src/dvsim/cli/run.py#L62-L72

That calls this function: https://github.com/lowRISC/dvsim/blob/0f1346640562da32bc399530b309487e9e1df832/src/dvsim/utils/subprocess.py#L28-L39

(With the wrong type for exit_on_failure btw, but who needs correct types?)

The problem is that function will basically always say that the command has timed out. The bug is due to the classic truthiness footgun that Python shares with Javascript. Unlike in Typescript where you can (with considerable effort) set up ESLint to ban truthiness bugs, I'm not aware of a way to do that in Python so you just have to be vigilant.

Here is the bug (and the other poll further down): https://github.com/lowRISC/dvsim/blob/0f1346640562da32bc399530b309487e9e1df832/src/dvsim/utils/subprocess.py#L53-L54

It needs to be if p.poll() is not None:.

poll() returns the exit code or None if the process has not exited. If the command succeeds then p.poll() returns 0, and if 0: will never succeed so it thinks the command times out.

主要语言
Python
星标
16
派生
23
平均合并
1 天 19 小时
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

lowRISC/dvsim 的其他 Issue

查看 lowRISC/dvsim 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。