Skip to content

[bug] Append-redirect to a ':'-containing filename under a /d/ drive-form path fails 'Invalid argument' (GNU and Git Bash both succeed — NTFS ADS vs extended-path handling) #359

Closed

Description

@caomengxuan666

Found by ecosweep4 lane (wt22/nest22; corpus: bats-core self-suite runlog test/.bats/run-logs/2026-09-30 14:48:26 UTC.log, worktree base a522eb3, release build; oracle WSL GNU Bash 5.3.0 script-file runs; Git Bash used as classification control only).

Reproducer

mkdir -p /d/any/dir
printf 'x\n' >>"/d/any/dir/2026-09-30 14:48:26 UTC.log"
echo "rc=$?"
  • rubash: <script>: line 2: Invalid argument, rc=1
  • GNU 5.3.0 (WSL): rc=0, file created
  • Git Bash 5.3.15 (same Windows filesystem): rc=0, file created (591-byte real file; cygwin creates it via ADS-capable open)

Contrast inside rubash itself:

  • /tmp/colon-dir/a:b.log append → rc=0 (succeeds — different path-conversion layer)
  • spaced paths (/tmp/dir with space/f 1.log) → fine
  • /d/… colon-free paths → fine

So only the drive-form (/d/→D:\) + colon-in-filename combination fails.

Suspected mechanism

The \?\ extended-length prefix forbids : in path components (raw NT semantics), while the plain Win32 path layer interprets name:stream as an NTFS alternate data stream and the open succeeds. It looks like the drive-form open path goes through an extended-prefix conversion (hence EINVAL) while /tmp-form does not, or uses a layer that allows the ADS interpretation. Git Bash demonstrates the ADS behavior is available on this exact NTFS volume.

Real-world hit

bats-core ≥1.9 names its per-run log file "<date> <HH:MM:SS> UTC.log" (bats-exec-suite:140) when test/.bats/run-logs/ exists; every per-test printf … >>"$BATS_RUNLOG_FILE" (bats-exec-test:190) then emits Invalid argument noise and the runlog is not written under rubash, while GNU/Git Bash write it. Tests still pass (no set -e on that line) — silent data loss + stderr pollution.

Probes

  • target/issue-suites/results/ecosweep4/colon-probe.sh (/d/ form → rc=1)
  • target/issue-suites/results/ecosweep4/colon-probe2.sh (/tmp form → rc=0)
  • instrumented run: target/ecosweep4-corpus/bats-dbg (bats-exec-test line 190 patched to dump DBG-RUNLOG=[…], shows the failure fires exactly on the colon timestamp path)

C source note

GNU side this is just a legal filename (open(2) on ext4/tmpfs). The Windows decision is ours: match MSYS/Git-Bash behavior (succeed via ADS interpretation for drive-form paths) or at minimum keep rubash's two path layers consistent (/tmp form already succeeds).

Activity

  1. added
    bug
    on Sep 30, 2026
  2. caomengxuan666 commented on Sep 30, 2026

    @caomengxuan666
    MemberAuthor

    Classified by wt22/p0fix (platform boundary, not lane-fixable): the colon filename needs Win32 ADS-unrepresentable syntax — CreateFileW returns EINVAL directly (python + Rust std double-verified; a ?\ prefix retry also EINVAL). The /tmp single-colon 'success' is actually an ADS stream (cmd /r proves a:b.log:). Git Bash's 'success' is cygwin PUA-encoding the illegal char as U+F03A (real name bytes EF 80 BA, PowerShell hex dump). A real fix needs a cygwin-style PUA path-encoding layer (encode on create + decode on enumerate/read; Windows tools would see mojibake names) — a cross-cutting design decision, kept open as its tracker.

  3. added a commit that references this issue on Oct 3, 2026
  4. caomengxuan666 commented on Oct 3, 2026

    @caomengxuan666
    MemberAuthor

    Landed on master (wt48/resid413): map_ntfs_colon_final_component in shell_path_to_windows encodes : in the last path component as U+F03A (Git Bash's proven approach on this volume, hex-dump verified) — > >> < test -f glob and cd all reach the same file across /d/ D:/ and relative spellings. Byte-identical to WSL GNU on the colon matrix. Residual: WinuxCmd ls displays raw F03A — display-side issue, not ours.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions