Skip to content

[bug] declare trace attribute: declare -F listing drops -t (declare -ft f lists as declare -f f); declare -f -t NAME prints the body instead of silently setting trace #217

Closed

Description

@caomengxuan666

Corpus: bash-preexec master d866ee (corpus2 lane first run). bash-preexec.sh:500 does declare -ft __bp_install __bp_hook_preexec_into_debug. Artifacts: target/issue-suites/results/corpus2/results/bash-preexec/diff-x.txt, probes probe/p3-trace.*, probe/p3b-tracelist.*.

Two facets, same builtin surface:

Facet 1 — declare -F listing drops the trace attribute. Reproducer (LF script file):

f() { :; }
declare -ft f
declare -F
  • GNU 5.3.0: declare -ft f
  • rubash (9bf2df9): declare -f f

Facet 2 — separated-flags form declare -f -t NAME prints the function body instead of silently setting the attribute. Reproducer:

h() { :; }
declare -f -t h
echo "after_sep_flags=$?"
  • GNU: no output, after_sep_flags=0 (attribute set silently; -t with a function name is an attribute-set, -f just limits the scope to functions)
  • rubash: prints the full function body (h () \n{ \n :\n}) — treats the -f as a display request and ignores -t as an attribute in this flag-combination, and the declare -F listing that follows shows declare -f h (attribute lost)

Impact: any framework that marks internal functions with declare -ft (bash-preexec does, for functrace/DEBUG-trap propagation of its hooks) loses the trace attribute in rubash — with set -o functrace semantics depending on it, preexec DEBUG-trap chains behave differently. The corpus diff also shows the attribute-mangled function list (see results/bash-preexec/diff-x.txt).

GNU C source owner: builtins/declare.def:48 (-t = "to make NAMEs have the trace' attribute"), builtins/declare.def:334 (*flags |= att_trace in the option parser); the display path distinguishes attribute-setting (nodefs/flags) from listing (show_name_attributes, builtins/declare.def:398region) — when names are given and an attribute flag like-tis present without a value, GNU sets the attribute and prints nothing;declare -F/declare -flistings renderdeclare -ft NAME` for traced functions (attribute bits in the printed declaration).

Classification: rubash-caused (byte-reproduced from identical script files on both shells). Not covered by #183/#189 (declare -p FUNCNAME / declare -p not-found) or #126 (declare -f carrier leak) — this is the -t attribute specifically.

Activity

  1. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(lane wt4/corpusfix,2026-09-27):根因修复 + 全形状矩阵与 WSL GNU 5.3.0 字节一致;源语料复跑(bash-preexec/tldr 转 CLEAN)。感谢报告!

  2. caomengxuan666 commented on Sep 28, 2026

    @caomengxuan666
    MemberAuthor

    Status update (ecosweep lane, 2026-09-28, rubash e207b0d release build): the pinned fixture tests/fixtures/corpus2/repro/declare_trace_attr.sh now runs byte-identical to WSL GNU bash 5.3.0. declare -F/-t handling is no longer reproducible at this commit.

  3. added
    bug
    area:builtins
    on Oct 17, 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

    area:builtinsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions