[ruby-cvs:73037] normal:r65937 (trunk): io.c (fptr_finalize_flush): close race leading to EBADF

normal at ruby-lang.org normal at ruby-lang.org
Sat Nov 24 03:19:07 JST 2018


normal	2018-11-24 03:19:07 +0900 (Sat, 24 Nov 2018)

  New Revision: 65937

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65937

  Log:
    io.c (fptr_finalize_flush): close race leading to EBADF
    
    The previous ordering was:
    
    a) notify waiting_fd threads of impending close
    b) waiting on busy list from a)
    c) invalidate fptr->fd
    d) calling close()
    
    However, it was possible for a new thread to enter
    the waiting_fd list while scheduling on b), leading
    to EBADF from those threads when we hit d).
    
    Instead, we now avoid triggering EBADF in other threads by
    reordering b) and c)
    
    a) notify waiting_fd threads of impending close
    c) invalidate fptr->fd
    b) waiting on busy list from a)
    d) calling close()
    
    cf. http://ci.rvm.jp/results/trunk-nopara@silicon-docker/1474526

  Modified files:
    trunk/io.c


More information about the ruby-cvs mailing list