JDK-4336824 : java.awt.MediaTracker.waitForID(int id,long ms) loops endlessly in some cases
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2000-05-09
  • Updated: 2002-12-19
  • Resolved: 2000-11-25
Related Reports
Duplicate :  
Description

Name: skT45625			Date: 05/09/2000


java version "1.3.0rc1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)

MediaTracker.waitForID(...) fails to recover from blocked images when waittime
is set to zero!
This is a bug in the waitForID(...) method itself the following code segment
from MediaTracker.waitForID(...) shows the problem:

	while (true) {
	    int status = statusID(id, first, first);
	    if ((status & LOADING) == 0) {
		return (status == COMPLETE);
	    }
	    first = false;
	    long timeout;
	    if (ms == 0) {
		timeout = 0;
	    } else {
		timeout = end - System.currentTimeMillis();
->		if (timeout <= 0) {
->		    return false;
->		}
	    }
	    wait(timeout);

if ms is 0 and (status & loading) stay equal to 0, then an endless loop will
result, because in this case the marked (->) statements will never be reached!

The same bug is also in the waitForAll(long ms).
(Review ID: 102835) 
======================================================================

Comments
WORK AROUND Name: skT45625 Date: 05/09/2000 It's better to just move the if (timeout <= 0) statement after the else block where it currently is contained in, instead of creating a workaround. ======================================================================
11-06-2004

EVALUATION Looks like an easy fix. This should be fixed for Ladybird, and likely Merlin as well. brent.christian@eng 2000-05-09 Name: biR10147 Date: 10/23/2000 ###@###.### The cause of this bug isn't in endless loop, but in missing notify() in some special cases. It seems that this bug is only reproducible on some special configurations (two processors are needed, but not enough to reproduce it). Not enough resources to fix it in Ladybird. ====================================================================== Here is another email from the engineers who investigated this bug: It is clear that the hang is not related to the endless loop (we agreed that it was submitter's mistake), but is related to missing notify. It looks very much like this bug is a duplicate of another one: 4332685 AbstractButton.getDisabledIcon can cause the VM to hang! (dual-processor box) Which was fixed by a change in MediaTracker (and is already integrated to Merlin). Since the submitter didn't provide any testcase or any information about his system (or answer any of the emails we sent), but just stated that programs with MediaTracker sometimes hang, I think we can close 4336824 as a duplicate of 4332685 without any bad feelings. eric.hawkes@eng 2000-11-24
24-11-2000