Skip to content

[P1][harvest] source 中的 exit 1 未终止执行:47-cipher 失败循环跑穿直到看门狗(exit-in-source 或 $? 传播面) (asset: WeilerWebServices/Powershell#LibreSSL/tests/testenc.sh) #798

Closed

Description

@caomengxuan666

来源

eco-harvest-ci 夜间 run 39078222286(windows test 层)verdict 分诊。

静态复现形态(只读分析,未执行)

asset 是 LibreSSL 的加密回环测试:47 个 cipher × (raw+base64),每个 cipher:

$cmd $i -e -k test < $test > $test.$i.cipher
$cmd $i -d -k test < $test.$i.cipher >$test.$i.clear
cmp $test $test.$i.clear
if [ $? != 0 ]; then exit 1; else /bin/rm ...; fi

沙箱里 ../apps/openssl 不存在 → 每次外部命令失败。GNU bash 语义:第一次 cmp 失败(或 $cmd 127)后 [ $? != 0 ] 成立 → exit 1 → 立即终止(source 中的 exit 终止整个 shell)。即 bash 只会跑 1 个 cipher 就退出。

harness tail(verdict 原样,截尾 8 行)

aes-256-cfb1 base64
niu: ../apps/openssl: No such file or directory
niu: ../apps/openssl: No such file or directory
aes-256-cfb8
niu: ../apps/openssl: No such file or directory
niu: ../apps/openssl: No such file or directory
aes-256-cfb8 base64
niu: ../apps/openssl: No such file or directory

cipher 列表是有序的:aes-128-cbc … aes-256-cfb1, aes-256-cfb8, … 共 47 项。tail 已推进到第 ~14 项且持续输出 —— 说明 exit 1(或使它成立的 $? != 0 判定)没有生效,循环在失败路径上继续跑,直到 14s 看门狗。

两个候选根因(需引擎侧定位)

  1. exit-in-source 控制流:source 上下文里 exit N 是否应该终止——GNU bash 会终止整个 shell;若 rubash 把 source 中的 exit 实现成"返回 source 调用点",for 循环就会继续(且测试框架或因此未感知终止意图)。
  2. $? 传播:外部命令 spawn 失败(No such file or directory)后的 $? 若不是 126/127 而是别的(0?),[ $? != 0 ] 恒假 → 同样跑完整个列表。

判据:tail 里循环在推进(输出逐 cipher 前进)而不是卡死在某条命令上,所以这不是慢 spawn,而是"本该终止没终止"。

GNU bash 对照预期

bash tests/testenc.sh(或 bash -c 'source testenc.sh')在第一个 cipher 的 cmp 失败后 rc=1 退出,总耗时 < 1s。

Activity

  1. added
    bug
    P1-high
    eco-harvest
    on Oct 18, 2026
  2. caomengxuan666 commented on Oct 18, 2026

    @caomengxuan666
    MemberAuthor

    票面前提更正(取证见 PR #807,独立复核证实):沙箱形态下 exit 1 本就不可达,47-cipher 循环跑穿是正确行为

    独立复核(worktree 干净检出 + WSL GNU bash 5.3.0 + 票面钉住的 testenc.sh@26193272 原文)证实 PR #807 的判定:本票“source 中的 exit 1 未终止执行”这一前提在沙箱形态下不成立,两个候选根因也都不可达。

    关键链条(票面静态分析漏掉的一步)

    票面预期“第一个 cipher 的 cmp 失败 → exit 1 → rc 1 退出”,但沙箱里 cmp 不会失败:

    1. cat $srcdir/openssl.cnf >$test;(line 21):重定向先把 p 截断为空文件,然后 cat 因 ./openssl.cnf 不存在而失败(GNU 实测 stderr 首行:testenc.sh: line 21: cat: ./openssl.cnf: No such file or directory)→ $test 是空文件。
    2. 每个 cipher 两条 $cmd(spawn 失败 127)的 > $test.$i.cipher / > $test.$i.clear 各自仍然创建空目标文件。
    3. cmp $test $test.$i.clear = 空对空 → rc 0 → [ $? != 0 ] 恒假 → 恒走 else 的 /bin/rm → exit 1 全程不可达。

    WSL GNU bash 5.3.0 实测沙箱形态:rc 0,stdout 恰 100 行,stderr 恰 201 行(201 = 49×4 条 spawn 失败 + 4 条 setup + 1 条 cat),整循环跑穿。PR #807 的 rubash 构建在同一资产上 stdout 逐字节一致(100/201/rc 0)。即 harness tail 里循环推进到 aes-256-cfb8 正是与 GNU 一致的正确行为,CI 的 HANG 是 ~400 次 spawn 在 2 核 runner × 8 workers 下超出 12s 看门狗的体量问题(#451 类),不是控制流缺陷。

    失败形态本身已另行钉死(PR #807 回归覆盖)

    提供 openssl.cnf 使 $test 非空后:首个 cmp 失败 → sourced exit 1 立即终止整个 shell,-c 与 source 驱动两路均 rc 1(AFTER-SOURCE 不打印)。tests/issue798_testenc_exit_in_source_regressions.rs 四测试钉死:沙箱跑穿存活、首失败整 shell 终止(-c)、交互会话同终止、spawn 失败 127 + 空重定向目标。

    结论

  3. added 2 commits that reference this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-highbugeco-harvest

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions