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
Fix: FreeBSD crash on multiplayer #9728
Conversation
On FreeBSD at least, FD_SET(-1, ptr); either causes a segfault or writes outside of the bounds of ptr. Since -1 is returned when socket() fails, this is always in valid and can never be read or written, so always return false in this case.
I do not think this is the correct solution for the bug you encounter. We should add an I have a hard time seeing a code-flow that could currently result in the above backtrace. You also don't mention how to reproduce this problem: could you indicate how you trigger this bug? As it should happen on any OS, just most OSes don't have issues with it, I guess ;) Basically, |
I created a PR to validate some cases where |
I started OpenTTD, then clicked on Multiplayer, then it crashed. |
Owh, another piece of information that could be really useful to debug this, is if you can run OpenTTD with But I am mostly curious if my PR triggers an assert .. would be nice. As this might be another FreeBSD mismatch :) |
This is with my fix (so no crash)
|
Right, indeed it is actually another problem that causes this issue in the end. I created #9730 to track this issue, so we can resolve it properly. Sadly, in GitHub you cannot convert a Pull Request to an issue. One of those quirks :) This PR patches up the crash, but doesn't actually addresses the real problem. Additionally, it causes a memory leak, as every time this happens the attached objects are not destroyed. So I am going to close this PR, and let's figure out what actually goes wrong :) Tnx for the info, and let's continue in #9730 :) |
On FreeBSD at least, FD_SET(-1, ptr); either causes a segfault or
writes outside of the bounds of ptr. Since -1 is returned when
socket() fails, this is always in valid and can never be read or
written, so always return false in this case.
Motivation / Problem
Fixes crash on (at least) FreeBSD
Description
Limitations
None
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.