arvidn / libtorrent

an efficient feature complete C++ bittorrent implementation
http://libtorrent.org
Other
5.26k stars 997 forks source link

force recheck with zero byte files gives mmap error #7790

Open toppk opened 1 week ago

toppk commented 1 week ago

Please provide the following information

libtorrent version (or branch):

$ rpm -q rb_libtorrent qbittorrent
rb_libtorrent-2.0.10-3.fc41.x86_64
qbittorrent-5.0.1-1.fc41.x86_64

please describe what symptom you see, what you would expect to see instead and how to reproduce it. 11/12/24 12:03 AM - File error alert. Torrent: "...". Reason: "... file_mmap (...) error: Invalid argument"


  1. start a torrent that creates a several files in a subdirectory
  2. start the torrent
  3. stop the torrent
  4. remove a file in a subdir and touch it, so it exists with zero bytes
  5. force recheck

I think I triggered this by using an older version of qbittorrent that would touch files at zero bytes, then switched to qbittorrent that used new mmap version of libtorrent which caused this error, but it's easy to reproduce using the procedure with just latest libtorrent. I tried on a simple torrent that didn't use subdirectories, and the force recheck didn't have any issues, so I used a torrent that creates lots of subdirs and it triggered immediately when following my procedure.

This was reported as well in qbittorrent here, but I couldn't find if it was reported here: https://github.com/qbittorrent/qBittorrent/issues/20398