Use `/proc/PID/mem` to access sandbox memory
- [ ] Test with both versions of used FC
- [ ] Add explicit handling for
NoopMemoryor implement more general memory mapping lookup
[!NOTE] Create memfile diffs by reading sandbox memory directly from /proc/PID/mem via a new mapped memory view, with UFFD providing the mapping.
- Memory diffing:
- Switch
MemoryDiffCreatorto read from a genericio.ReaderAtand use a new process memory view instead of a tmp memfile.- In
Sandbox.Pause, attempt snapshot with/dev/null(fallback to memfile if unsupported), obtain FC PID and UFFD mapping, buildmemory.View, and pass it to diff writer.- UFFD integration:
- Extend
MemoryBackendwithMapping(ctx)and implement inUffd(exposes mapping) andNoopMemory(returns nil).- Refactor
userfaultfd.Userfaultfdto usem *memory.Mapping(renamema), addMapping()accessor, and update offset lookups.- Memory mapping/view module (
internal/sandbox/uffd/memory):
- Add
MappingwithGetOffsetandGetHostVirtAddr,Regionhelpers, andView(implementsio.ReaderAtover/proc/PID/mem), including specific errors.- Add comprehensive tests for mapping (offset/host-virt), view reading across regions/gaps, and UFFD-driven reads/writes/fault behavior.
- Misc:
- Make
block.Tracker.Hasunexported (has) and update tests.- Update test utils to return detailed diff errors for byte slices.
Written by Cursor Bugbot for commit 7d148a050ea0c618166fb70b86448f9f1a93ab48. This will update automatically on new commits. Configure here.
Waiting for https://github.com/e2b-dev/infra/pull/1385 merge.
@codex review
cursor review
Current blocker is the NoopMemory mapping—the actual maps we should be able to get from /proc/PID/maps, but if we want to improve just the non-build pause we can let that one be handled normally.
It is failing on integration test, because they are not using the custom FC.