link icon indicating copy to clipboard operation
link copied to clipboard

[EMFILE] How to handle too many opened files error?

Open abique opened this issue 4 years ago • 4 comments

Hi,

Currently Ableton Link does not provide a good way to check if link could successfully initialize and is ready to do its job. I've found that it is even worse, if it can't properly initialize due to "too many opened files" error then the destruction of the link object may never return and wait forever on joining threads doing nothing.

Maybe I've missed something?

Regards, Alex

abique avatar Nov 23 '21 21:11 abique

You haven't missed anything. And this is indeed tricky. Can you confirm that the issue persists on the latest commit on 'master'? We re-worked the thread and lifetime management and would be interested to know if joining the threads blocks after these changes.

cdi-ableton avatar Nov 24 '21 14:11 cdi-ableton

I've tested it with the latest commit yesterday and I even tried with the latest version of asio (1.21 maybe?). The issue still remains.

abique avatar Nov 24 '21 15:11 abique

To reproduce it:

  • limit the number of files to N
  • open N files (minus what's already opened, stdin, stdout, stderr, ...) see if ableton link works
  • open N-1 files in another process, and check again
  • open N-2 files, ...

I don't know how many files ableton link needs, at least 2 I suppose, one for epoll and one for the socket. Good to try all the failure scenarios.

Good luck!

abique avatar Nov 24 '21 15:11 abique

Hey, I tried opening files until I hit the limit from LinkHut and other apps. Of cause LinkHut will not be able to connect when it can't open a socket anymore, but I never got it into a state where it could not join the worker thread when destructing Link.

If you have a way to reproduce this, could you maybe try to replace the run() in https://github.com/Ableton/link/blob/bea3834be189f893dd495a8169f6b46e1d1f2cca/include/ableton/platforms/asio/Context.hpp#L65 with a run_one() and check if that changes the behavior?

fgo-ableton avatar Nov 30 '21 10:11 fgo-ableton