Help save net neutrality! Learn more.
Close

#127 crash (infinite loop) on disconnect from ics

closed-fixed
ics: fics (30)
5
2008-06-09
2008-05-18
Anonymous
No

My system:

Slackware 12.0
GTK+-2.10.13

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 network.cc 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) {
i=read(handle,sm,amount);
if ((i==0)&&(errno==0)) {
if (buffer.empty()) {
close();

By changing the line
if ((i==0)&&(errno==0)) {
to
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.

Discussion

  • 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
    user_id=23863
    Originator: NO

    fixed in the CVS, will be in 1.1.2.

     

Log in to post a comment.