Jump to content
Excelsior Forums
Sign in to follow this  
qqxx2000

Compiled Program runs in an infinite loop

Recommended Posts

I have a simple binary search method. It runs fine with JRE. But after I compile it with JET, the exe program runs in an infinite loop.

In JRE:

D:\>java JETTest

70==0,105.0==49.5,140==0

35==70,70.0==49.5,70==0

17==35,52.0==49.5,35==0

8==17,43.0==49.5,17==0

12==8,47.0==49.5,17==8

14==12,49.0==49.5,17==12

15==14,50.0==49.5,17==14

14==15,49.0==49.5,15==14

14

Run JET compiled exe, I got an infinite loop that keeps spitting out

8==0,43.0==49.5,17==0

The print-outs are just for debugging purpose to show the problem.

I attached the source code below.

I'm using JET v6.4 Professional Edition with Java SE 6 Update 7.  I also tried the Maintenance Pack 1. It doesn't work either.

I also tried to use all default settings to set up the JET project (also attached below). But it didn't help.

-----------------------------------------

import java.awt.geom.Point2D;

public class JETTest {

public static int binarySearch(Point2D.Double p, double[] ms) {

    boolean found = false;

    int upperBound = ms.length - 1;

    int lowerBound = 0;

    int prevIndex = 0;

    while (!found) {

int targetIndex = (upperBound + lowerBound) / 2;

if (targetIndex == prevIndex)

    return targetIndex;

double value = ms[targetIndex];

System.out.println(targetIndex+"=="+ prevIndex+","+value+"=="+p.getX()+","+upperBound +"=="+ lowerBound);

System.out.flush();

if (value == p.getX())

    return targetIndex;

if (value > p.getX())

    upperBound = targetIndex;

else//else less

    lowerBound = targetIndex;

prevIndex = targetIndex;

    }

    return 0;

}

public static void main(String[] args) {

double[] ms = new double[] {35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,

43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,

53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,

63.0,64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,

73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,

83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,

93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,

103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,

111.0,112.0,113.0,115.0,117.0,118.0,119.0,120.0,

121.0,122.0,123.0,124.0,125.0,126.0,127.0,128.0,

129.0,130.0,131.0,133.0,134.0,135.0,137.0,139.0,

141.0,142.0,144.0,147.0,149.0,151.0,155.0,156.0,

159.0,160.0,161.0,163.0,165.0,177.0,179.0,181.0,

185.0,186.0,189.0,191.0,193.0,194.0,207.0,208.0,

209.0,210.0,216.0,218.0,219.0,220.0,237.0,251.0,

254.0,255.0,267.0,268.0,269.0,270.0,277.0,283.0,290.0};

int i = binarySearch(new Point2D.Double(49.5,49.5), ms);

System.out.println(i);

}

}

-----------------------

%%Excelsior JET v6.4 project file

-compilewithfixedheap-

-gendll-

-genstackalloc+

-genstacktrace-

-global-

-gui-

-ignoreclassduplication+

-ignorememberabsence+

-inline+

-splashgetfrommanifest-

-classabsence=HANDLE

-compilerheap=0

-heaplimit=0

-inlinelimit=100

-inlinetolimit=1000

-javacommandline:=java JETTest

-jetcplastpage:=PageCompile

-jetrt=Desktop

-jetvmprop=-Djet.jit.fast -Djet.gc.heaplimit:0

-main=JETTest

-outputdir=.

-outputname=Untitled

-stacklimit=900000

-startupprofile=./Untitled.startup

!classpathentry .

  -pack=none

  -protect=all

  -optimize=all

!end

!module ./Untitled.usg

Share this post


Link to post
Share on other sites

Thank you for your report.

We have reproduced the issue that seems to be provoked by a bug in dead code elimination ( "return 0;" is unreachable code in your sample program).

If you replace

  while (!found)

with

    while (true)

it starts working.

We will fix the issue soon. Please contact Excelsior Support (java at excelsior-usa.com) if you need a hotfix.

Share this post


Link to post
Share on other sites

Is there a way to turn off dead code elimination without turning off other optimization?

I'm asking this because this method is a part of a large project worked by many people. So.. you know. This bug made me worried about potential problems else where.

Share this post


Link to post
Share on other sites
Is there a way to turn off dead code elimination without turning off

other optimization?

No.

Do you experience any other problems (misbehavior of the compiled application) or you'd like to disable it  just for sure?

Share this post


Link to post
Share on other sites

No, I haven't found other problems yet.

Yes, I want to be able to search for potential problems to double check.

After you told me the cause, I turned on the warnings when compiling with JET and got thousands of warnings about unreachable code. It is too many to search for unless there is a specific pattern.

I guess I probably will ask for a hot fix. Thanks for the help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×