Closed tdm4 closed 6 years ago
Just a little more background: In OpenBSD, if you start a daemon with rcctl, it uses your current tty/terminal as STDIN (FD 0). However, once you quit that terminal or log out, running fstat -u _ioq3 then shows STDIN as 'bad'. It's then that whenever Con_FlushIn is called, the function can get stuck in an infinite loop if STDIN stops returning -1 and it seems it never finishes.
Using tcflush() is a better solution as it was designed to flush properly (and it's a POSIX function)
Hi, I have strange bug with similar symptoms (i.e. full hangs with one core at 100% after a random time from start) on Gentoo Linux which only shows if I’m enabling opus support. I’m not using this engine directly, but a modified fork for UrbanTerror. Your patch seems to fix this. Therefore thank you!
Fixed by https://github.com/ioquake/ioq3/pull/356.
https://github.com/ioquake/ioq3/blob/d28e667e469c68223f6969130e23c4ea1f09cc5e/code/sys/con_tty.c#L87
When I run ioq3ded with rcctl, after some unspecified amount of time, the game stops responding, CPU shoots up to about 90%. I suspected because STDIN isn't actually being used since it's running as a daemon. If I run ioq3ded in a tmux window, I never get this issue.
Here's the stack trace:
I've done a lot of testing. I can't reproduce it reliably enough, I just have to leave the server running and once in a while the read for STDIN_FILNO returns a -1 and the while loop becomes infinite.
Perhaps we need to replace those two lines with: