Closed rare-magma closed 2 years ago
It might a file descriptor leak somewhere in the code.
Could you please:
strace -f $yourtool
that reproduces the descriptor leak and post the last few hundred lines of the output?Also when the gotop
starts reporting "too many files" please run sudo lsof -p $(pidof gotop)
. It shows all files opened by the process. And then post the output here.
I pushed a possible fix to ataattr
branch. Please try the branch and let me know if you see any improvement with the file descriptor leak.
I encountered this problem when I was using github.com/anatol/smart.go v0.0.0-20220404164659-a19872369963
as seen in this PR: https://github.com/xxxserxxx/gotop/pull/221
To reproduce this issue it's necessary to run gotop in a machine with at least a SATA disk. Instructions here (https://github.com/xxxserxxx/gotop)
My machine specs: Fedora Silverblue 36.20220613.0 Linux kernel v5.17.13-300.fc36.x86_64 go version go1.18.2 linux/amd64 2 SATA SSDs 2 HDDs
I've executed gotop with the following arguments:
sudo gotop --layout disk --rate 10s --color nord --
here's the output of sudo strace -f gotop
:
strace.txt
output of sudo lsof -p $(pidof gotop)
:
lsof.txt
I've tried to reproduce the issue with the atattr branch and haven't managed to get the error so far. I'll try again tomorrow.
I ran a simple test with code similar to what you have in gotop
and I do not see any fd leaks. Try my latest changes and let me know if you have any problems.
@rare-magma how did the fix work? Do you still see the fd leak?
@anatol I tried to reproduce again with your latest changes and wasn't successful so I believe the issue is solved. Thanks!
I'm integrating smart.go with gotop (cli activity monitor) to gather info about the disks temperature in a machine in this PR: https://github.com/xxxserxxx/gotop/pull/221
Unfortunately after a few minutes, either smart.Open() or sm.ReadSMARTData() or sm.ReadSMART() end up causing a "too many open files" error. Any idea on what might be the cause for this issue?