Skip to content

[declare] readonly 变量的属性更改静默接受:declare -i R 于 readonly R 变成 -ir(GNU 报 readonly variable 拒绝、保持 -r)(P2) #528

Closed

Description

@caomengxuan666

来源:huck 443 条 divergence issue 全量审计(issues-audit)we-diverge 增量,A 组高危 A6;huck 侧 issue #734 互证。
审计基准:GNU bash 5.3.0(WSL stdin 法 oracle)× rubash origin/master 764b9dd debug 构建。

最小复现

readonly R=1; declare -i R; declare -p R
GNU bash 5.3.0 rubash 764b9dd
stderr bash: declare: R: readonly variable (无)
stdout declare -r R=1(保持) declare -ir R=1(属性被改)

依据

  • readonly 保护的不只是值,还有属性:bash 对 readonly 变量的属性更改一律拒绝(variables.c 的 mark_readonly 检查路径)。
  • 削弱 readonly 保证:整数属性可被第三方代码静默注入。

跨实现互证(huck)

优先级建议

P2(语义反向:GNU 拒我接受;readonly 保护被静默架空)。

Activity

  1. added
    bug
    gnu-baseline
    P2-medium
    on Oct 12, 2026
  2. caomengxuan666 commented on Oct 12, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by #560 (Wave2a). Root cause, vendored-bash anchoring (sig.c:333/trap.c:187/declare.def:893/962-981 per issue), and RED-then-GREEN regression evidence in the PR.

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

    P2-mediumbuggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions