Skip to content

Panic (SIGABRT, exit 134) on non-UTF-8 bytes in argv — std::env::args() unwrap #3025

Open

Description

@sdewell

First off — thank you for maintaining rtk. The 0.43 releases (the never-worse output guard, the grep engine fix) have made it noticeably more trustworthy in day-to-day agent use, and that work is appreciated.

Summary

rtk aborts with a Rust panic (SIGABRT, exit 134) when any command-line argument contains bytes that aren't valid UTF-8. The panic fires in std::env::args()'s per-argument unwrap, before the wrapped command runs.

Reproduction (rtk 0.43.0, macOS arm64, zsh)

The pattern below is the leading bytes of a double-encoded UTF-8 sequence — the kind of byte fragment you end up grepping for when hunting mojibake in a repo, which is how we hit this in real work:

$ printf '\xc3\xa2\xe2\x80\xa0\n' | rtk grep -c $'\xc3\xa2\xe2\x80'

thread 'main' panicked at /rustc/.../library/std/src/env.rs:875:51:
called `Result::unwrap()` on an `Err` value: "â\xE2\x80"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
134

Expected

Either pass the raw bytes through to the underlying engine (system grep handles them fine under LC_ALL=C), or exit with a normal, clear error message — anything but an abort.

Notes

Thanks again for all the work that goes into this tool.

Activity

  1. pszymkowiak commented on Jul 16, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 94%

    Summary

    Non-UTF-8 bytes in argv cause std::env::args() unwrap panic (SIGABRT/exit 134) before the wrapped command runs; switch to args_os() with lossy/graceful handling.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/main.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. mgwedd commented on Jul 26, 2026

    @mgwedd

    Opened #3224 for this. Root cause is run_fallback in src/main.rs calling std::env::args(), which aborts on any non-UTF-8 argument. The uses args_os()/OsString so the original bytes are reproduced unchanged. It derives lossy strings only for display. restore_double_dash in src/core/args_utils.rs had the same call problem and I made the same fix there.

  3. KuSh commented on Oct 23, 2026

    @KuSh
    Collaborator

    One more reach for this, from #4727 (rtk ruff now calls restore_double_dash, which reads std::env::args()): with rtk invoked by an absolute path whose directory name is not UTF-8, rtk ruff check sub panics (exit 101) on that head, where develop 5ab6291 ran it. rtk git status from the same binary already panics on develop for the same reason. Invoked by name through PATH (argv[0] = rtk, the hook's form), neither panics. #3224 switches restore_double_dash to args_os(), which covers this call too.

  4. guryanov-a commented on Nov 5, 2026

    @guryanov-a

    Still reproduces on rtk 1.1.0 (macOS arm64, zsh), the current release: rtk grep -c $'\xf0\x9d' <file> panics with called Result::unwrap() on an Err value: "\xF0\x9D" and exits 101. We hit it through the Claude Code hook, which routes ordinary shell commands through rtk, so the agent's command fails outright. #3224 would fix it.

    Written by Claude Opus 5.5 in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions