You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cli: convert -o can leave a truncated file and panics on IO errors #855
simlin convert -o <path> truncates the destination file and then writes to it, unwrapping every IO result.
A failure part-way through (disk full) leaves a truncated file where the user's previous good file was, and the CLI panics with a backtrace instead of printing an error.
It should write through simlin_engine::io::atomic_write (temp file, fsync, rename) and report IO errors with die!.
render -o and equations --output use the same pattern and should get the same fix.
Low: only IO failures mid-write are exposed (conversion errors are caught before the file is opened), and the CLI is mainly a testing tool.
But the failure destroys the file being overwritten. simlin-serve already saves through atomic_write for this reason.
Fix
Write to stdout through io::stdout() when no output path is given, rather than opening /dev/stdout as a file (a rename cannot target it).
For a named path, call atomic_write and die! with the path and the OS error on failure.
One helper used by convert, render and equations covers all three.
Pointers
src/simlin-cli/src/main.rs: Command::Convert and Command::Render arms, print_equations
src/simlin-engine/src/io.rs: atomic_write
src/simlin-serve/src/writer.rs: atomic_write_to, an existing caller
changed the title [-]cli: convert -o output write is non-atomic and panics on IO errors[/-][+]cli: convert -o can leave a truncated file and panics on IO errors[/+]on Oct 12, 2026
Activity
[-]cli: convert -o output write is non-atomic and panics on IO errors[/-][+]cli: convert -o can leave a truncated file and panics on IO errors[/+]