Skip to content

[bug] declare -ft (function trace attribute) does not propagate the RETURN trap to the function #343

Closed

Description

@caomengxuan666

Found by gnusweep3 lane (cat5 t033; WSL GNU Bash 5.3.0 oracle, worktree 0fe8d0f).

Repro:

f() { return 5; }
declare -ft f
trap 'echo R' RETURN
f
echo "rc=$?"

GNU 5.3.0: prints R then rc=5 — the per-function trace attribute makes f inherit the caller's RETURN trap (same as set -o functrace).
rubash: prints only rc=5 — RETURN trap not fired for the traced function.

GNU C owner: execute_cmd.c execute_function() (the run_return_trap calls at execute_cmd.c:5378/5399/5407 gate on the function's trace flag) + trap.c:1328 run_return_trap().
Artifacts: target/issue-suites/results/gnusweep3/cat5/case/t033.; minimal target/issue-suites/results/gnusweep3/probes/min/m09-return-trace.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 30, 2026
  2. added a commit that references this issue on Sep 30, 2026
  3. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt20/deepsweep (536abb86): declare -ft RETURN trace fires (execute_cmd.c:5291-5295 trace_p port at the function-call boundary).

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

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions