This is a copy of 4317961 which was for SPARC (which is now fixed.)
Problem occurs when thr_getstate returns a flag value of TRS_NONVOLATILE
in fetch_top_frame_fast. The i386 code for fetch_top_frame_fast returns
a null pc/sp, restarts the thread, and tries to suppend again. Unfortunately,
the thread with the infinite loop is always in a state in which TRS_NONVOLATILE
is returned, so GC never runs.
Compiler safepoints do not work.
Run the appended program with following commandline
and it will hang with both compilers
java -Xcomp -verbose:gc sf
Run it with following commandline and it terminates properly:
java -Xint -verbose:gc sf
The program hangs if the method loop is compiled because
the runtime cannot properly suspend the endless loop.
I have verified that both Compiler 1 and Compiler 2 (server) are
emitting safepoint information.
----------------
public class sf {
static public boolean _xx = true;
public static void main(String[] args) {
new Srdjan().start();
}
public void start() {
new TesterThread().start();
new GCThread().start();
}
class TesterThread extends Thread {
// trick compiler 2 in believing that this is not and endless loop
public void loop (int n) {
long counter = 0;
while (_xx) {
if (n == 0) {
_xx = false;
}
}
}
public void run () {
System.out.println("Start loop");
loop(3);
}
}
class GCThread extends Thread {
public void run () {
System.out.println("Starting GC loop");
long counter = 0;
while (true) {
try { sleep(250); } catch (InterruptedException ix) {}
System.gc();
counter++;
if (counter == 10) {
_xx = false;
return;
}
}
}
}
}
Problem occurs when thr_getstate returns a flag value of TRS_NONVOLATILE
in fetch_top_frame_fast. The i386 code for fetch_top_frame_fast returns
a null pc/sp, restarts the thread, and tries to suppend again. Unfortunately,
the thread with the infinite loop is always in a state in which TRS_NONVOLATILE
is returned, so GC never runs.
Compiler safepoints do not work.
Run the appended program with following commandline
and it will hang with both compilers
java -Xcomp -verbose:gc sf
Run it with following commandline and it terminates properly:
java -Xint -verbose:gc sf
The program hangs if the method loop is compiled because
the runtime cannot properly suspend the endless loop.
I have verified that both Compiler 1 and Compiler 2 (server) are
emitting safepoint information.
----------------
public class sf {
static public boolean _xx = true;
public static void main(String[] args) {
new Srdjan().start();
}
public void start() {
new TesterThread().start();
new GCThread().start();
}
class TesterThread extends Thread {
// trick compiler 2 in believing that this is not and endless loop
public void loop (int n) {
long counter = 0;
while (_xx) {
if (n == 0) {
_xx = false;
}
}
}
public void run () {
System.out.println("Start loop");
loop(3);
}
}
class GCThread extends Thread {
public void run () {
System.out.println("Starting GC loop");
long counter = 0;
while (true) {
try { sleep(250); } catch (InterruptedException ix) {}
System.gc();
counter++;
if (counter == 10) {
_xx = false;
return;
}
}
}
}
}
- relates to
-
JDK-4899545 Server compiler emits redundant membar-volatile instructions
-
- Closed
-
-
JDK-4375080 nsk/regression/b4336548 test hangs on multiprocessor system under Ladybird
-
- Closed
-