Skip to content

v0.8.1

Choose a tag to compare

@cwt cwt released this 09 Aug 16:42
· 285 commits to main since this release

szn v0.8.1

23 commits since v0.8.0. 870 tests passing.


Headline: Reliability Hardening and Zig 0.16 Compliance

v0.8.1 is a patch release that closes out the remaining bug tracker entries
(#300–#346) and brings the codebase into full Zig 0.16 compliance. The
highest-impact fixes are performance (O(n²) → O(1) hot-path caches), memory
safety (UAF, double-free, leaks eliminated), and error handling (91 silent
catch {} suppressions replaced with proper logging).


Performance: O(n) → O(1) Hot-Path Caches

The v0.8.0 performance audit (#300–#310) identified 11 bottlenecks in the
render and event loops. All have been resolved with targeted caching:

  • isPaneValid (#305) — added valid: bool to Pane; now an O(1)
    pointer check instead of an O(N·M·P) tree walk on every PTY event.
  • anyDisplayClientBehind (#303) — added behind_count: u32 to
    Server; O(1) counter instead of traversing display_clients on every
    loop iteration. Backpressure leak fixed: disconnected clients now clear
    the counter on all four removal paths.
  • Foreground process name (#300) — last_foreground_name cached on
    Window; getForegroundProcessName() syscall skipped when the cached
    name matches. 1-second rate limit prevents stale reads.
  • Pane border format (#304/#307) — border_format_cached /
    border_format_gen on Pane; format is expanded once and reused until
    pane-border-format option changes. Allocator mismatch corrected
    (now uses pane's grid allocator).
  • Status line (#309) — per-DisplayClient cache; skipped entirely
    when the server is not dirty and the client width is unchanged.
  • Regressions from the performance sweep (#300–#310) — five defects
    introduced by the initial optimization pass were corrected:
    • Status line cache double-free (the yazi crash) — cache now owns an
      independent copy, freed in DisplayClient.deinit.
    • behind_count leak on client disconnect — all four paths now
      saturating-decrement the counter.
    • Border format generation counter never incremented —
      cmdSetOption now bumps session.border_format_gen.
    • Auto-rename freeze — last_foreground_name aliased win.name,
      making the skip check always true; replaced with timestamp-based
      rate limit.

Memory Safety: UAF, Double-Free, and Leak Fixes

Bug Fix
#312 processInput UAF when an action destroys the active pane or session — added guard
#313 Window title callback called allocator.free on a Session arena pointer
#314 Border format strings allocated with wrong allocator (pane grid vs gpa)
#324 cmdRenameWindow leaked window name into session arena
#338 Status line string duplicated per frame when cache hit — removed redundant allocation
#315/#320/#323 Command/layout desync on pane removal — layout tree and pane list kept in sync
#316/#317 Sixel refcount leaks on vertical screen shrink and history eviction
#318 Layout split failure left parent pane dimensions un-restored
#319 Darwin errno enum check; window name stack pointer fixup; invalid free
#321 Uncapped loop in CSI 'Z' handler — CPU exhaustion DoS
#322 Synchronous blocking write in server response dispatch

Bug Fixes

Parser & Configuration (#325, #326, #327, #328, #329, #330, #334)

  • set -u directive was silently ignored in config parser
  • Substring flag matching in mapCommandToAction could match wrong command
  • Copy-mode single-line backward selection yank failure
  • Format string truncation specifier sliced UTF-8 codepoints
  • Missing OSC discard transition on buffer overflow (input injection)
  • Input parser dropped interrupting Escape (0x1B) control bytes
  • Dropped keystroke on interrupted UTF-8 continuation sequence

Grid & Rendering (#311, #316, #317, #318, #321, #322)

  • Multiline prompt cursor jumping and text scrambling during line editing
  • Sixel leaks on grid rotation and split dimension rollback
  • Rotation desync between Window.panes array and layout tree
  • CSI 'Z' (shift-in) handler caused CPU exhaustion

Server & Dispatch (#312, #315, #319, #320, #323, #325, #335, #336, #337)

  • UAF in processInput when action destroys active pane
  • Command/layout desync on cmdBreakPane / cmdJoinPane
  • Darwin errno enum check; window name stack pointer fixup
  • set -u parser; code duplication in key binding flags and window index resolution
  • Command table switched from function pointer dispatch to inline for

Key Binding & Format (#326, #327, #328, #329, #330, #331, #332, #333, #334)

  • Multiple parser edge cases in key binding, mode copy, and format strings

Zig 0.16 Compliance

Bug Fix
#339 91 instances of catch {} replaced with `catch
#343 detectNested() in main.zig now uses init.environ_map instead of std.c.getenv
#344 main() signature changed from void to !void (Zig 0.16 rule #1)
#345 std.process.Args.Iterator replaced with init.minimal.args.toSlice(arena) — eliminates N heap allocations per invocation
#341 initCapacity() calls updated to = .empty + ensureTotalCapacity for consistency

Three items initially flagged as violations (#340, #342, #346) were verified
against the actual Zig 0.16 std lib source and confirmed as false positives:

  • std.StringHashMap / std.AutoHashMap managed types still exist and are not deprecated
  • std.ArrayList.toOwnedSlice() still exists in both managed and unmanaged variants
  • The codebase is a raw-POSIX syscall codebase (only one std.Io import
    exists in the entire tree) — the io capability pattern does not apply

Bug Tracker Status

Metric v0.8.0 v0.8.1
Total bugs 300 346
Fixed 286 327
False positive 9 17
Intentional 1 1
Open 0 0

All 346 bugs are now resolved.


Testing

Metric v0.8.0 v0.8.1
Passing tests 802 870
New regression tests — 68