JDK-6680485 : Wrong error-handling with Solaris-specific interruptible I/O (Solaris)
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: solaris
  • CPU: generic
  • Submitted: 2008-03-26
  • Updated: 2010-12-03
  • Resolved: 2010-08-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0u19Fixed
Related Reports
Relates :  
Description
In some circumstances Hotspot's hpi code may be fooled into assuming an initial socket connect call happened when it was actually skipped because of thread interruption. 

These mistakes go back at least to 1.4.2, but possibly earlier.

Comments
EVALUATION Interruptible I/O is going away completely with JDK 6. It is disabled by default in JDK 7. This does not appear to represent a customer reported bug, rather a concern due to reading the source code. Will not fix.
30-08-2010

SUGGESTED FIX For 1.4.2_22 only: --- 1.4.2_22/hpi_solaris.hpp 2008-05-19 10:51:39.985264400 -0400 +++ 1.7.0/hpi_solaris.hpp 2008-05-19 10:51:40.515855200 -0400 inline int hpi::connect(int fd, struct sockaddr *him, int len) { do { int _result; INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result, os::Solaris::clear_interrupted); - if ((_result == OS_ERR) && (errno == EINTR)) { + + // Depending on when thread interruption is reset, _result could be + // one of two values when errno == EINTR + + if (((_result == OS_INTRPT) || (_result == OS_ERR)) && (errno == EINTR)) { /* restarting a connect() changes its errno semantics */ (The comment would be better as "whether and when thread interruption happens" rather than "when thread interruption is reset.")
19-05-2008

EVALUATION Fortunately, for 1.5.0_20+, 1.6.0_10+, and 7.0 code, the lack of initialization of errno is likely to be extremely unlikely. Doubly fortunately, the related problem implied by the original suggested fix (a rewrite of the "if" gating the 2nd hpi connect call) was based on mis-reading of code and is not needed and that part of the suggested fix has been deleted. However the 1.4.2 code (including update 20 code as of this writing) is broken in the opposite way compared to the description: The second connect will never happen in response to a a thread interruptions of the first connect. This kept the probabily of the stack corruption reported in CR 6670408 very low and prevented the connection with the CR 6343810 change from being detected for a very long time. So a 2nd part to the suggested fix has been added for the 1.4.2u20+ code only, but this *must not* be applied until after the fix for 6670408 is applied.
19-05-2008

SUGGESTED FIX --- ../old/os_solaris.inline.hpp Tue Mar 11 17:40:38 2008 +++ os_solaris.inline.hpp Tue Mar 11 18:07:55 2008 @@ -89,10 +89,11 @@ _setup; \ _before; \ OSThread* _osthread = _thread->osthread(); \ if (_thread->has_last_Java_frame()) { \ /* this is java interruptible io stuff */ \ + errno = 0; \ if ((os::is_interrupted(_thread, _clear)) \ || ((_cmd) < 0 && errno == EINTR \ && os::is_interrupted(_thread, _clear))) { \ _result = OS_INTRPT; \ } \ (The need for a change to hpi_solaris.hpp was mistaken)
26-03-2008