Skip to content

awk: --debug / -D with -f panics #168

Open

Description

@sylvestre

The debugger is not implemented: --debug currently prints a bytecode table.
That code reads the positional program text, so with -f it panics. With
-D -f, the source spans are also sliced out of the wrong text.

Reproduction

Rust (incorrect)

$ echo 'BEGIN { x = 1 }' > d.awk
$ ./target/release/awk --debug -f d.awk </dev/null
thread 'main' panicked at src/main.rs:86:30:
called `Option::unwrap()` on a `None` value
# Exit code: 2

-D -f prog.awk input, with a longer program, panics at src/main.rs:93 with
start byte index ... is out of bounds.

GNU: starts the interactive debugger, which reads commands from stdin.

Test

#[test]
fn debug_with_program_file_does_not_panic() {
    let ts = uutests::util::TestScenario::new("awk");
    ts.fixtures.write("prog.awk", "BEGIN { y = 2 }\n");
    ts.cmd(crate::TESTS_BINARY)
        .args(&["--debug", "-f", "prog.awk"])
        .run()
        .stderr_does_not_contain("panicked");
}

Exposed by the GNU awk test suite: dbugarray1, dbugarray2, dbugarray4,
dbugeval2, dbugeval3, dbugeval4, dbugtypedre1, dbugtypedre2, watchpoint1 (they
need the debugger to pass).

Activity

  1. added
    bug
    good first issue
    crash
    on Nov 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

    bugcrashgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions