已关闭
[issue] 编译器超时仅报 "status 124",timed_out 未透出 #16
cezarbbb创建于  9月9日关闭于  23 天前
cezarbbb
9月9日 创建
name about title labels
BotMetric 问题单 报告 BotMetric 中可复现的问题 [Issue] 编译器超时仅报 cargo provider exited with status 124,无 timeout 字样、timed_out 未结构化透出 bug, diagnostics, low

问题概述

--compiler-timeout-secs 触发超时后,错误为 BM302 "cargo provider exited with status 124":消息无 timeout 字样,诊断中无结构化 timed_out 字段,用户需知晓 124 为超时惯例才能归因。首次出现版本:v1.0.0 即存在,v1.1.0 延续。受影响对象:启用 --cargo-check / --rustc-check / --clippy-check 的所有输入。实际影响:超时与编译器其他失败(如依赖缺失)难以区分,自动化归因困难。本问题涉及诊断字段口径,不涉及指标数值。

影响范围

项目 内容
分析对象 ☑ Cargo 软件包 ☑ 工作空间 ☑ 独立 .rs 文件(编译器诊断层,与输入类型无关)
受影响的指标、规则或报告字段 BM302 诊断消息与结构化字段(timed_out 未透出);--compiler-timeout-secs 语义
影响程度 ☑ 轻微
临时规避办法 ① 知晓 124 = 编译器超时惯例,按退出码归因;② 自动化中按 wall 时间与退出码组合判断

复现步骤

最小源码样例:夹具 fixtures\slow-compile(fib(38) 泛型宏展开,冷编译 x86 约 4.7s / ARM64 约 14.79s,确保可触发 2s 超时)。自包含最小样例如下(与测试夹具 slow-compile 同构:泛型宏单态化 + 生成大文件;下述命令中的 <slow-compile> 即指向该样例目录):

slow-compile/
├── Cargo.toml
└── src/
    ├── lib.rs
    └── gen.rs(由下方脚本生成,约 5100 行)

Cargo.toml:

[package]
name = "slow-compile"
version = "0.1.0"
edition = "2021"

src/lib.rs:

// slow_compile.rs - heavy generic monomorphization to stress compiler timeout tests.

pub mod gen;

pub trait Visitor {
    type Out;
    fn visit(&self, depth: usize) -> Self::Out;
}

macro_rules! make_node {
    ($name:ident) => {
        pub struct $name {
            pub children: Vec<Box<dyn Visitor<Out = String>>>,
        }
        impl Visitor for $name {
            type Out = String;
            fn visit(&self, depth: usize) -> String {
                let mut acc = format!("{}node", depth);
                for c in &self.children {
                    acc.push_str(&c.visit(depth + 1));
                }
                acc
            }
        }
    };
}

make_node!(NodeA);
make_node!(NodeB);
make_node!(NodeC);
make_node!(NodeD);
make_node!(NodeE);
make_node!(NodeF);
make_node!(NodeG);
make_node!(NodeH);

pub fn build_deep() -> NodeA {
    fn leaf(d: usize) -> Box<dyn Visitor<Out = String>> {
        struct Leaf {
            depth: usize,
        }
        impl Visitor for Leaf {
            type Out = String;
            fn visit(&self, _d: usize) -> String {
                format!("leaf{}", self.depth)
            }
        }
        Box::new(Leaf { depth: d })
    }
    let mut children: Vec<Box<dyn Visitor<Out = String>>> = Vec::new();
    for i in 0..64 {
        children.push(leaf(i));
    }
    NodeA { children }
}

src/gen.rs 生成脚本(Python,与测试夹具 gen.rs 同构:5102 行、约 74 个生成函数,每个函数 64 条 wrapping_add 链):

# gen_gen.py — 在 slow-compile 目录下执行:python gen_gen.py
with open("src/gen.rs", "w", encoding="utf-8") as f:
    f.write("// gen.rs - generated large file for compiler timeout tests\n\n")
    for i in range(74):
        f.write(f"pub fn gen_fn_{i}(x: u64) -> u64 {{\n")
        f.write("    let mut acc = x;\n")
        for k in range(64):
            f.write(f"    acc = acc.wrapping_mul(3).wrapping_add({k});\n")
        f.write("    acc\n}\n\n")
  1. BM110 analyze <slow-compile> --cargo-check --compiler-timeout-secs 2 --format json
  2. 检查错误消息与诊断字段中是否含 timeout 字样或 timed_out 字段
  3. 记录 wall 时间与进程清理情况
  4. x86 与 ARM64 各执行一次并对比

预期结果

错误消息标明超时(含 timeout 字样),或诊断含结构化字段(如 timed_out=true),使超时可被机器归因。

实际结果

BM302 "cargo provider exited with status 124",无 timeout 字样、无 timed_out 字段;x86 wall 2.09s(SIGKILL)、ARM64 wall 2.59s(2.15s 终止 cargo),无孤儿进程残留。ARM64 批次 9 复现(R6)实测通过。证据:x86_linux\records\batch-09\verify-groupC_6-3.txt;arm_linux\records-arm64\batch-09\verify-groupC_6-3.txt、arm_linux\records-arm64\batch-06\out\t66-slow-timeout2.json。

证据原文(x86_linux\records\batch-09\verify-groupC_6-3.txt):

=== 6-3 复现:编译器超时 BM302 仅显示 status 124 ===
exit=3
status: partial
code: BM302 | level: error | message: cargo provider exited with status 124
  含 timeout 字样? False

证据原文(arm_linux\records-arm64\batch-09\verify-groupC_6-3.txt):

=== 6-3 复现:编译器超时 BM302 仅显示 status 124 ===
命令:BM110 analyze fixtures/slow-compile --cargo-check --compiler-timeout-secs 2 --format json
(须带 --cargo-check 启用编译器诊断,否则 compiler.diagnostics=disabled、compiler_run 为空、status=complete;等价配置键为 compiler.command_timeout_seconds)
exit=3
status: partial
code: BM302 | level: error | message: cargo provider exited with status 124
  含 timeout 字样? False
compiler_run.exit_code: 124;实测 wall time 2.59s(cargo 于 2s 被终止,ARM 冷编译需 14.79s,超时窗口充裕)。
与 x86 归档逐项一致(exit 3 / partial / BM302 消息逐字相同 / 无 timeout 字样)。
结论:复现成立——BM302 消息未明示"因超时被终止",compiler_run.timed_out 未透出,超时仅复用退出码 124 惯例。

证据原文(arm_linux\records-arm64\batch-06\out\t66-slow-timeout2.json,共 947 行,节选 compiler_run 与 BM302 诊断部分):

  "compiler_run": {
    "command": [
      "cargo",
      "check",
      "--manifest-path",
      "fixtures/slow-compile/Cargo.toml",
      "--message-format=json",
      "--offline"
    ],
    "toolchain": "rustc 1.98.0 (88d9e12ae 2026-08-18)",
    "exit_code": 124
  },
  "errors": [
    {
      "code": "BM302",
      "message": "cargo provider exited with status 124"
    }
  ],

……(节选,完整文件见 arm_linux\records-arm64\batch-06\out\t66-slow-timeout2.json;顶层 diagnostics 数组重复同一条 BM302:{"file": null, "line": null, "column": null, "code": "BM302", "level": "error", "message": "cargo provider exited with status 124", "source": "analysis"},无 timed_out 字段)

分析环境与范围

项目 内容
BotMetric 版本或提交号 v1.1.0(commit 8ef52f6);对照 v1.0.0(commit 8cfb20e)
操作系统与架构 x86_64 Linux(rustc/cargo 1.95.0)+ aarch64 Linux(rustc/cargo 1.98.0),均 root 用户
软件包 / 目标 / 特性 / 范围参数 slow-compile(目录输入);--cargo-check --compiler-timeout-secs 2 --format json
文件数 / 代码行数 1 个 .rs 源文件(fib(38) 泛型宏展开)
模块层级 / 重复窗口 单文件;不涉及重复分析

指标、发现与报告证据

  • ☑ 已说明发现条目的编号、严重级别、位置和 human_message:BM302 / error / 无位置 / "cargo provider exited with status 124"
  • ☑ 已附 analysis-report:完整 JSON 输出存于 t66-slow-timeout2.json 与 verify-groupC 证据文件
  • ☐ 指标口径:不适用(诊断透出问题,指标计算正常)
  • ☑ 已说明 Cargo/独立文件口径差异:不适用(编译器诊断层与输入类型无关)

性能与资源证据

项目 内容
冷缓存 / 热缓存 冷缓存(编译无缓存复用,超时必然触发)
执行次数 / 基线 每平台 ≥2 次(原批次 + 批次 9 复现),结果稳定
总耗时 x86 wall 2.09s(SIGKILL);ARM64 wall 2.59s(2.15s 终止 cargo)
处理器占用 / 内存峰值 未采样;无孤儿进程残留(两平台均确认)
采样工具 无
测试数据集规模 / 硬件条件 slow-compile 单文件;x86_64 与 aarch64 Linux 服务器(root)

附件与提交确认

  • ☑ 已检索现有问题单,确认不是重复问题
  • ☑ 已提供最小复现步骤、预期结果和实际结果
  • ☑ 已明确指标公式、统计范围和实际证据(如适用)——本条为诊断透出问题,不涉及指标
  • ☑ 已完成日志、配置、源码和附件脱敏(输出不含本机用户路径)
likedislike
WWangZijun成员
25 天前 关联了pull request:fix: expose compiler timeouts and document SARIF results (issue#16_22)
WangZijun成员
25 天前 评论:

https://gitcode.com/xuanwu/bot-metric/pull/14

结论:

  • 问题可以复现:修复前的最小复现与回归测试确认了 issue 描述的行为。
  • 问题可以修复:当前分支的针对性测试和全量质量门禁均已验证修复结果。

具体修复:

  • 为 Cargo、Clippy 和 rustc 编译器运行结果增加向后兼容的 timed_out 结构化字段。
  • 保留超时退出码 124 与 partial 语义,并让 BM302 明确说明进程因超时终止。
  • 增加真实 Cargo 超时、序列化兼容性与三类 provider 传播路径的回归覆盖。
likedislike
VVaynNecol成员
23 天前 关闭了 issue