Files
Velix-MPV-Core/DOCS
NRK 3cd66d2fd7 command: avoid crashing the player with mmap
mmap in inherently crashy due to the file changing underneath
and requires esoteric SIGBUS handling [0] to use properly.

to reproduce, simply use "overlay-add" from a lua script with
invalid stride set and observe mpv crashing with SIGBUS.

here we're just copying the file content (introduced in
549a9ea) and munmaping it immediately so there's no real need
to be using mmap to begin with. avoid the issue entirely by just
reading the file directly with fseek+fread with optimization for
the common stride case.

one notable difference is that since dup-ed fds share same
offset, the source "fd" that's coming from client will now have
it's offset modified. `pread` could avoid this issue but it's
not supported on windows.

[0]: https://www.sublimetext.com/blog/articles/use-mmap-with-care
2026-03-12 15:58:53 +01:00
..
2025-01-04 15:59:49 +02:00
2021-05-11 22:18:40 +02:00
2025-12-21 20:08:20 +01:00
2026-01-25 20:56:42 +01:00