-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent crash in Unix JoystickImpl
with too many file descriptors
#1941
Conversation
I was thinking of just replacing I don't think we should jump to conclusions a bit too fast. We don't know what the user might be doing with their system. I can imagine for scientific/prosumer purposes that need some kind of visualisation SFML could have been used if it wasn't for this limitation. https://man7.org/linux/man-pages/man2/select.2.html
|
Something along the lines of: #include <poll.h>
bool hasMonitorEvent()
{
// This will not fail since we make sure udevMonitor is valid
int monitorFd = udev_monitor_get_fd(udevMonitor);
pollfd fds{ monitorFd, POLLIN, 0 };
return (poll(&fds, 1, 0) > 0) && ((fds.revents & POLLIN) != 0);
} |
@vittorioromeo Would it be possible to fix this problem with the |
1cff977
to
e7fabfd
Compare
Codecov Report
@@ Coverage Diff @@
## 2.6.x #1941 +/- ##
=======================================
Coverage ? 7.17%
=======================================
Files ? 184
Lines ? 15787
Branches ? 4161
=======================================
Hits ? 1132
Misses ? 14523
Partials ? 132 Continue to review full report at Codecov.
|
@vittorioromeo I updated the commit to the |
@fvallee-bnx can you give this branch a try? Note that you may need to adjust more, since the master branch is undergoing major changes towards SFML 3 |
This patch can also be backported to 2.6.x without issues. |
@eXpl0it3r looks good to me (patch backported to 2.5.3 - no crash). Thanks a lot! |
…ge number of file descriptors are open.
e7fabfd
to
3e7380f
Compare
I've backported the change to SFML 2.6 then we can forward merge it onto master later on |
Description
Fixes #1900 by using the check @fvallee-bnx suggested. Note that
hasMonitorEvent
is used inisConnected
here:joystickList[index].plugged
might return the wrong value in that case, but it seems fine as it is an edge case (over 1024 file descriptors). Not sure if there's a nice way to avoid a hard limit on file descriptors, but this should at least solve the crash.Tasks
How to test this PR?
It needs to be tested on Linux, I have not had a chance to do that yet.