Conversation
PR SummaryLow Risk Overview Written by Cursor Bugbot for commit c1636a4. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } | ||
|
|
||
| mm, err := mmap.MapRegion(f, int(size), mmap.RDWR, 0, 0) | ||
| mm, err := mmap.MapRegion(f, int(size), unix.PROT_READ|unix.PROT_WRITE, 0, 0) |
There was a problem hiding this comment.
Bug: raw unix PROT flags conflict with mmap-go own flag encoding, silently switching MAP_SHARED to MAP_PRIVATE.
mmap-go defines its own constants (not POSIX PROT_* values):
- mmap.RDONLY = 0
- mmap.RDWR = 1
- mmap.COPY = 2 (triggers MAP_PRIVATE)
- mmap.EXEC = 4
unix.PROT_READ|unix.PROT_WRITE = 0x1|0x2 = 3, which mmap-go interprets as RDWR|COPY (1|2=3). In mmap_unix.go the COPY branch fires first in the switch:
case inprot© != 0: // 3 & 2 = 2, non-zero -> TRUE
prot |= syscall.PROT_WRITE
flags = syscall.MAP_PRIVATE // writes never reach the file
With MAP_PRIVATE, all writes to the mmap stay in process memory and are never flushed to the backing file. This breaks ExportToDiff which reads dirty blocks from the file via unix.CopyFileRange/unix.SyncFileRange -- those reads will see stale/zero data.
The original mmap.RDWR (= 1) correctly produced MAP_SHARED. This line should be reverted to mmap.RDWR.

No description provided.