rakshasa / rtorrent

rTorrent BitTorrent client
https://github.com/rakshasa/rtorrent/wiki
GNU General Public License v2.0
4.15k stars 414 forks source link

rtorrent hangs on munmap, msync #1164

Open Zygitty opened 2 years ago

Zygitty commented 2 years ago

rtorrent 0.9.8/0.13.8 becomes unresponsive while downloading, when memory usage exceeds 1GB (5GB are allocated) at download rates of >60MB/sec. It will hang for a few seconds, then memory usage drops to <100MB and the download resumes. dtruss shows system calls to msync and munmap during the hang which occur each time:

29028/0x4e7597:  statfs64(0x600002B87360, 0x7FF7BCC56A28, 0x0)       = 0 0
dtrace: error on enabled probe ID 1700 (ID 963: syscall::write_nocancel:return): invalid kernel access in action #13 at DIF offset 68
29028/0x4e7597:  statfs64(0x6000008BB110, 0x7FF7BCC56A28, 0x0)       = 0 0
29028/0x4e7597:  statfs64(0x600000894000, 0x7FF7BCC56A28, 0x0)       = 0 0
29028/0x4e7597:  msync(0x147116000, 0x800996, 0x1)       = 0 0
29028/0x4e7597:  munmap(0x147116000, 0x800996)       = 0 0
29028/0x4e7597:  msync(0x14D122000, 0x800996, 0x1)       = 0 0
29028/0x4e7597:  munmap(0x14D122000, 0x800996)       = 0 @0
29028/0x4e7597:  msync(0x14F126000, 0x800996, 0x1)       = 0 0
...
29028/0x4e7597:  statfs64(0x6000008BCC80, 0x7FF7BCC56A28, 0x0)       = 0 0
29028/0x4e7597:  statfs64(0x6000008A80F0, 0x7FF7BCC56A28, 0x0)       = 0 0
29028/0x4e7597:  sigaction(0x12, 0x7FF7BCC57368, 0x7FF94C64E7A8)         = 0 0
29028/0x4e7597:  select(0x1, 0x7FF7BCC572E0, 0x0, 0x0, 0x7FF7BCC57360)       = 0 Xqż?0
29028/0x4e7597:  select(0x1, 0x7FF7BCC572E0, 0x0, 0x0, 0x7FF7BCC57360)       = 0 ??0
dtrace: error on enabled probe ID 1700 (ID 963: syscall::write_nocancel:return): invalid kernel access in action #13 at DIF offset 68
29028/0x4e7597:  sigaction(0x12, 0x7FF7BCC57348, 0x0)        = 0 0
29028/0x4e7597:  open_nocancel("/\0", 0x1100004, 0x0)        = 36 ask0
29028/0x4e7597:  fstatfs64(0x24, 0x7FF7BCC56290, 0x0)        = 0 ack0

29028/0x4e7597:  statfs64(0x600002B87360, 0x7FF7BCC56A28, 0x0)       = 0 $0
dtrace: error on enabled probe ID 1700 (ID 963: syscall::write_nocancel:return): invalid kernel access in action #13 at DIF offset 68
29028/0x4e7597:  statfs64(0x6000008BB110, 0x7FF7BCC56A28, 0x0)       = 0 @0
29028/0x4e7597:  statfs64(0x600000894000, 0x7FF7BCC56A28, 0x0)       = 0 0
29028/0x4e7597:  msync(0x1044EF000, 0x800333, 0x1)       = 0 0
29028/0x4e7597:  munmap(0x1044EF000, 0x800333)       = 0 0
29028/0x4e7597:  msync(0x104CF0000, 0x800333, 0x1)       = 0 0
29028/0x4e7597:  munmap(0x104CF0000, 0x800333)       = 0 0
29028/0x4e7597:  msync(0x1054F1000, 0x800333, 0x1)       = 0 0
...
29028/0x4e7597:  statfs64(0x600002584199, 0x7FF7BCC56A28, 0x0)           = 0 0
29028/0x4e7597:  sigaction(0x12, 0x7FF7BCC57368, 0x7FF94C64E7A8)                 = 0 0
29028/0x4e7597:  select(0x1, 0x7FF7BCC572E0, 0x0, 0x0, 0x7FF7BCC57360)           = 0 0
29028/0x4e7597:  select(0x1, 0x7FF7BCC572E0, 0x0, 0x0, 0x7FF7BCC57360)           = 0 0
dtrace: error on enabled probe ID 1700 (ID 963: syscall::write_nocancel:return): invalid kernel access in action #13 at DIF offset 6
8
29028/0x4e7597:  sigaction(0x12, 0x7FF7BCC57348, 0x0)            = 0 0
29028/0x4e7597:  open_nocancel("/\0", 0x1100004, 0x0)            = 42 0
29028/0x4e7597:  fstatfs64(0x2A, 0x7FF7BCC56290, 0x0)            = 0 0
29028/0x4e7597:  getdirentries64(0x2A, 0x7FE678024600, 0x2000)           = 696 0
29028/0x4e7597:  close_nocancel(0x2A)            = 0 0

29028/0x4e7597:  statfs64(0x600002B86AA0, 0x7FF7BCC56A28, 0x0)           = 0 0
29028/0x4e7597:  statfs64(0x600002B87360, 0x7FF7BCC56A28, 0x0)           = 0 0
dtrace: error on enabled probe ID 1700 (ID 963: syscall::write_nocancel:return): invalid kernel access in action #13 at DIF offset 6
 8
29028/0x4e7597:  statfs64(0x6000008BB110, 0x7FF7BCC56A28, 0x0)           = 0 @0
29028/0x4e7597:  statfs64(0x600000894000, 0x7FF7BCC56A28, 0x0)           = 0 0
29028/0x4e7597:  msync(0x11DB85000, 0x800000, 0x1)               = 0 ?uN0
29028/0x4e7597:  munmap(0x11DB85000, 0x800000)           = 0 I???dq0
29028/0x4e7597:  msync(0x120B86000, 0x800000, 0x1)               = 0 0
29028/0x4e7597:  munmap(0x120B86000, 0x800000)           = 0 0
29028/0x4e7597:  msync(0x11EB86000, 0x800000, 0x1)               = 0 0
...
29028/0x4e7597:  statfs64(0x6000025843F1, 0x7FF7BCC56A28, 0x0)           = 0 0
29028/0x4e7597:  statfs64(0x600002584409, 0x7FF7BCC56A28, 0x0)           = 0 0
29028/0x4e7597:  sigaction(0x12, 0x7FF7BCC57368, 0x7FF94C64E7A8)                 = 0 0
29028/0x4e7597:  select(0x1, 0x7FF7BCC572E0, 0x0, 0x0, 0x7FF7BCC57360)           = 0 0
29028/0x4e7597:  select(0x1, 0x7FF7BCC572E0, 0x0, 0x0, 0x7FF7BCC57360)           = 0 0
dtrace: error on enabled probe ID 1700 (ID 963: syscall::write_nocancel:return): invalid kernel access in action #13 at DIF offset 6
 8
29028/0x4e7597:  sigaction(0x12, 0x7FF7BCC57348, 0x0)            = 0 0
29028/0x4e7597:  open_nocancel("/\0", 0x1100004, 0x0)            = 42 0
29028/0x4e7597:  fstatfs64(0x2A, 0x7FF7BCC56290, 0x0)            = 0 .
29028/0x4e7597:  getdirentries64(0x2A, 0x7FE66E9A9200, 0x2000)           = 696 0
29028/0x4e7597:  close_nocancel(0x2A)            = 0 0

With the download rate limited to 250KB/sec, these calls are much briefer and don't cause a hang:

53742/0x5cacb0:  statfs64(0x600003918001, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x600003918019, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x600003790020, 0x7FF7BB58EA28, 0x0)           = 0 sigaction0
53742/0x5cacb0:  statfs64(0x600003790040, 0x7FF7BB58EA28, 0x0)           = 0 recvfrom0
53742/0x5cacb0:  statfs64(0x6000014D7840, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014F8050, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  msync(0x105BB9000, 0x4008DD, 0x1)               = 0 0
53742/0x5cacb0:  munmap(0x105BB9000, 0x4008DD)           = 0 0
53742/0x5cacb0:  msync(0x1053B7000, 0x4008DD, 0x1)               = 0 0
53742/0x5cacb0:  munmap(0x1053B7000, 0x4008DD)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C0FF0, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C32F0, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C0F00, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C35C0, 0x7FF7BB58EA28, 0x0)           = 0 0

 53742/0x5cacb0:  statfs64(0x600003790040, 0x7FF7BB58EA28, 0x0)           = 0 0
 53742/0x5cacb0:  statfs64(0x6000014D7840, 0x7FF7BB58EA28, 0x0)           = 0 0
 53742/0x5cacb0:  statfs64(0x6000014F8050, 0x7FF7BB58EA28, 0x0)           = 0 0
 53742/0x5cacb0:  msync(0x1057B8000, 0x4008DD, 0x1)               = 0 0
 53742/0x5cacb0:  munmap(0x1057B8000, 0x4008DD)           = 0 0
 53742/0x5cacb0:  statfs64(0x6000014C0FF0, 0x7FF7BB58EA28, 0x0)           = 0 0
 53742/0x5cacb0:  statfs64(0x6000014C32F0, 0x7FF7BB58EA28, 0x0)           = 0 0
 53742/0x5cacb0:  statfs64(0x6000014C0F00, 0x7FF7BB58EA28, 0x0)           = 0 0

53742/0x5cacb0:  statfs64(0x600003790020, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x600003790040, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014D7840, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014F8050, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  msync(0x1053B7000, 0x4008DD, 0x1)               = 0 0
53742/0x5cacb0:  munmap(0x1053B7000, 0x4008DD)           = 0 0
53742/0x5cacb0:  msync(0x105BB9000, 0x4008DD, 0x1)               = 0 0
53742/0x5cacb0:  munmap(0x105BB9000, 0x4008DD)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C0FF0, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C32F0, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C0F00, 0x7FF7BB58EA28, 0x0)           = 0 0
53742/0x5cacb0:  statfs64(0x6000014C35C0, 0x7FF7BB58EA28, 0x0)           = 0 0

MacOS 12.3, 32GB ram, APFS on an SSD with write speed of 108MB/sec