Skip to content

πŸ› [BUG] Non-atomic model file write β€” crash leaves corrupt fileΒ #225

Closed

Description

@ajianaz

Description

download_hf_file writes model files directly to final path using std::fs::write. If the process crashes or is interrupted during write, a partial/corrupt file remains on disk.

On next run, the file exists check passes, so it won't re-download β€” but the corrupt file causes ONNX loading to fail with confusing errors.

Affected Code

  • crates/uteke-core/src/embed/engine.rs line 155

Fix

Write to a temporary file (e.g., model_q4.onnx.tmp) and rename atomically after successful write. On startup, delete any leftover .tmp files.

Found by Cora v0.4.4 scan.

Activity

  1. added
    bug
    scope:core
    priority:high
    cora-scan
    on Jun 7, 2026
  2. ajianaz commented on Jun 7, 2026

    @ajianaz
    CollaboratorAuthor

    Fixed in v0.0.11 (PR #234)

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

    bugcora-scanpriority:highscope:core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions