Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Lua function utils.readdir() leaks file descriptors #4045
mpv version and platform
Hm, my version seems to be pretty old, but I'm also pretty lazy and as far as I can tell from the source code ( https://github.com/mpv-player/mpv/blob/master/player/lua.c ) the bug doesn't seem to be fixed in HEAD yet.
Create an empty folder:
Create the following Lua script and name it "readdir-bug.lua":
Run the script:
The script should call utils.readdir() 1024 times successfully, and the final error message should be "Playing: /dev/null\nFailed to recognize file format." like this:
The script only manages to call utils.readdir() 1018 times successfully; then the file descriptors of the mpv process are exhausted, and the remaining 6 calls fail. After that, mpv is unable to open any further files, so it even fails to open /dev/null. The reason is probably a missing closedir() call in the function script_readdir() in player/lua.c.