StateStore and ImageCache Lack Synchronization #12

Open
opened 2026-02-22 08:41:29 +00:00 by rawan · 0 comments
Member

Location:

  • crates/chvm-lib/src/vm/manager.rs:25-128 - StateStore
  • crates/chvm-lib/src/oci/cache.rs:35-182 - ImageCache

Issue:
Both StateStore and ImageCache use an in-memory HashMap that is read-modify-written and then persisted to disk, with NO internal locking. Concurrent operations (e.g., vm start + vm create in different terminals) can cause:

  1. Lost updates to the state/index
  2. Corrupted JSON files
  3. Duplicate or missing VM entries

Example Scenario:

Thread 1: Load state.json (contains VM1, VM2)
Thread 2: Load state.json (contains VM1, VM2)
Thread 1: Add VM3, save state.json (now has VM1, VM2, VM3)
Thread 2: Add VM4, save state.json (now has VM1, VM2, VM4 - VM3 is lost!)
**Location:** - `crates/chvm-lib/src/vm/manager.rs:25-128` - `StateStore` - `crates/chvm-lib/src/oci/cache.rs:35-182` - `ImageCache` **Issue:** Both `StateStore` and `ImageCache` use an in-memory `HashMap` that is read-modify-written and then persisted to disk, with NO internal locking. Concurrent operations (e.g., `vm start` + `vm create` in different terminals) can cause: 1. Lost updates to the state/index 2. Corrupted JSON files 3. Duplicate or missing VM entries **Example Scenario:** ``` Thread 1: Load state.json (contains VM1, VM2) Thread 2: Load state.json (contains VM1, VM2) Thread 1: Add VM3, save state.json (now has VM1, VM2, VM3) Thread 2: Add VM4, save state.json (now has VM1, VM2, VM4 - VM3 is lost!) ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
geomind_code/my_hypervisor#12
No description provided.