Help save net neutrality! Learn more.

#127 crash (infinite loop) on disconnect from ics

ics: fics (30)

My system:

Slackware 12.0

eboard 1.1.1 sometimes crashes after some time of inactivity. I can reproduce the crash by logging into fics and typing exit on the console. I think the crash is due an infinite loop that happens while disconnecting without properly closing the connection. Also, the crash doesn't happen when eboard is run with the option -debug. The function

int BufferedConnection::consume(int handle, int amount)

in line 175 of reads:

int BufferedConnection::consume(int handle, int amount) {
int i,j;
char sm[2048];
if (amount>2048) amount=2048;
// global.debug("I/O","consume-in");
while(1) {
if ((i==0)&&(errno==0)) {
if (buffer.empty()) {

By changing the line
if ((i==0)&&(errno==0)) {
if (i==0) {

the problem disappears (as far as I could test). I believe the original line is wrong because, according to the man page of READ(2), errno is set only when the return value of read is -1. When the remote side closes the connection, read returns 0 (0 bytes read), and errno keeps the value of the last failing system call. I checked that when -debug is not active, errno is 11 after the read call, so it never closes the connection. If -debug is active, errno is 0 after the read call, and it closes the connection. I guess that happens because the previous system call was the output to the debug log file, which might clear errno.

I didn't read the code to see if my fix would break other parts. So far, everything seems to be running smooth.


  • Felipe Bergo

    Felipe Bergo - 2008-06-09
    • assigned_to: nobody --> bergo
    • status: open --> closed-fixed
  • Felipe Bergo

    Felipe Bergo - 2008-06-09

    Logged In: YES
    Originator: NO

    fixed in the CVS, will be in 1.1.2.


Log in to post a comment.