JDK-4863822 : (se) selector read/write values out of sync with underlying values used to poll the channel
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2003-05-14
  • Updated: 2007-01-15
  • Resolved: 2007-01-15
Related Reports
Duplicate :  
Name: dk106046			Date: 05/14/2003

The read/write values in a selector can get out of sync with the underlying read/write values 
used to poll the channel.

A client/server application which creates many threads, each of which is available to process a read or
write from the same channel. Each time a selector is finished with by a thread it is disposed (after
100 uses by default). During reading from a channel, the read/write interest on the selector is changed
so that read interest is removed whilst reading, and restored after reading.

As deregistration (implDereg) alters the order of the unerlying list of file interests by copying the
last record to the one to be deregistered, then removing the last record, it is possible that the 
deregsitration is in process whilst the last record is being updated by a read operation, such that
the modification of the read interest (either adding or removing it) gets lost. 
It is not sufficient to synchronize on the selector being de-registered, you also have to synchronize
on the last one in the list to safely deregister.

There is no minimal set of code which reproduces this, it requires the full client/server Nio test
from the SVT suite.

EVALUATION The description is correct. This bug will be fixed as 6429204 in jdk7. The /dev/poll and epoll Selectors are not impacted by this issue.

EVALUATION Not for Mantis. -- ###@###.### 2003/5/15