rakshasa / libtorrent

libTorrent BitTorrent library
http://rtorrent.net/downloads/
GNU General Public License v2.0
883 stars 210 forks source link

fix(poll_epoll.cc): add exception handling for m_table array allocation #242

Open Moret84 opened 1 year ago

Moret84 commented 1 year ago

The try-catch block has been added to handle the std::bad_alloc exception that may occur when allocating memory for the m_table array. If the exception is thrown, an internal_error is raised with a message indicating that too much space was requested.

This pull-request is more a "report an issue" than a real fix. I recently encountered an issue that prevented me to use rtorrent inside a docker container. The issue is caused by a huge value of the system variable _SC_OPEN_MAX, that is directly used to allocate an array. More informations here and here. As I had a hard time finding the issue, I think it would be interesting to report the issue with a more accurate message. I am not sure at all this is the right fix. Please let me know if I can do anything other.

Thanks for your read and your time.