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
fix(fspy): use memfd for Linux shared memory (#523)
## Motivation
Stop Linux file-access tracking from consuming the container's `/dev/shm` quota and crashing with `SIGBUS`.
## Changes
- Replaces POSIX shared memory with a sealed `memfd`.
- Uses an abstract Unix socket broker to send the descriptor to each opener.
- Runs the broker asynchronously and keeps the preload client synchronous.
- Stops new opens when the owner is dropped while keeping existing mappings valid.
- Sets close-on-exec and derives the mapping length from the sealed descriptor.
- Covers concurrent and invalid opens.
- Updates the constrained-`/dev/shm` fixture to succeed.
Fixes#353
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
# Changelog
2
2
3
+
-**Fixed** Automatic file-access tracking on Linux now works in containers and Kubernetes runners with limited `/dev/shm` space ([#353](https://github.com/voidzero-dev/vite-task/issues/353), [#523](https://github.com/voidzero-dev/vite-task/pull/523)).
3
4
-**Fixed** Windows automatic input tracking now records executable image reads when process creation performs the lookup inside `NtCreateUserProcess` ([#518](https://github.com/voidzero-dev/vite-task/pull/518)).
4
5
-**Fixed** Failures while waiting for a started task process to exit no longer incorrectly say the process failed to spawn ([#515](https://github.com/voidzero-dev/vite-task/pull/515)).
5
6
-**Fixed** Missing env vars requested through `@voidzero-dev/vite-task-client` now return `undefined` instead of `null`, preserving Vite production `NODE_ENV` semantics when builds run through `vp run` ([#508](https://github.com/voidzero-dev/vite-task/pull/508)).
Copy file name to clipboardExpand all lines: crates/fspy_shm/README.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,10 @@ The public API is defined in [`src/lib.rs`](src/lib.rs).
29
29
30
30
The channel hides that difference with its lock file. [`ChannelConf::sender`](../fspy_shared/src/ipc/channel/mod.rs) opens and locks the receiver's exact lock-file path before it calls `fspy_shm::open`. The receiver removes that path before dropping the owner, so a sender that starts later fails before opening shared memory.
31
31
32
-
## Backend boundary
32
+
## Platform designs
33
33
34
-
At this point in the stack, `fspy_shm` delegates mapping creation and opening to the [`shared_memory`](https://crates.io/crates/shared_memory) crate. Because callers use only the API above, later changes can replace the backend on each platform without changing the channel protocol.
34
+
Each platform keeps its implementation rationale beside its source:
35
+
36
+
-[Linux: `memfd` with a descriptor broker](src/linux/README.md)
37
+
38
+
At this point in the stack, Windows and macOS still delegate mapping creation and opening to the [`shared_memory`](https://crates.io/crates/shared_memory) crate.
The Linux backend stores data in a sealed `memfd`. A process opens the mapping by connecting to an abstract Unix-domain socket and receiving the descriptor from a broker. It then accesses the mapped memory directly.
4
+
5
+
The backend must avoid `/dev/shm` quotas, expose a large mapping without allocating every page up front, support synchronous opens from preload code, and stop new opens when the owner is dropped without invalidating existing views.
| POSIX shared memory | Rejected because Linux stores it in `/dev/shm`, so it shares that mount's size limit. |
12
+
| System V shared memory | Rejected because IPC namespace limits affect availability and the owner must explicitly remove the segment. |
13
+
| Sparse temporary file | Rejected because dirty pages may reach disk, and sharing the path and deleting the file require additional handling. |
14
+
|`memfd` with descriptor broker | Selected. It avoids `/dev/shm` and System V limits. The kernel keeps it alive while a descriptor or mapping refers to it. |
15
+
16
+
The broker accepts and serves clients with Tokio. Opening is synchronous because it can run before `main`, so creating an owner must occur inside a Tokio runtime.
17
+
18
+
## Why not `shared_memory`
19
+
20
+
`shared_memory` uses POSIX `shm_open` on Linux and cannot construct a mapping from a `memfd`, so it retains the `/dev/shm` dependency.
21
+
22
+
## Lifetime semantics
23
+
24
+
Dropping the owner stops the broker. Existing views remain valid; later opens fail.
0 commit comments