Infinite loop when compiling with optimization

RESOLVED FIXED

Status

Rhino
Core
RESOLVED FIXED
13 years ago
13 years ago

People

(Reporter: Mike C., Assigned: Igor Bukanov)

Tracking

Details

Attachments

(1 attachment)

(Reporter)

Description

13 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; T312461; YComp 5.0.0.0; .NET CLR 1.1.4322; .NET CLR 2.0.50215)
Build Identifier: 

Rhino compiler gets in a infinite loop when 
compiled with -opt greather than zero, for this file: 

------------------------------­------------ 
// file infloop.js 
function infLoop(inStr) { 
  var i = -1; 
  while ((i = inStr.indexOf("%")) != -1) { 
    inStr = inStr.replace("%", ""); 
  } 

  return inStr; 
}

var str = infLoop("abc%def"); 
------------------------------­------------ 


Reproducible: Always

Steps to Reproduce:
1. save the above code in a file (infloop.js)
2. java -cp js.jar org.mozilla.javascript.tools.jsc.Main -opt 1 infloop.js

Actual Results:  
Compiler hangs, with processor at 100%.
If compiled with -opt 0 the compilation succeeds and a class file is generated.



Tested and reproduced with 1_5R5 and 1_6R1.

In 1_5R5 the loop is in the class
org.mozilla.javascript.optimizer.Optimizer
in
    private static void
    typeFlow(OptFunctionNode fn, Block theBlocks[])

I did not debug with 1_6R1 sources but I assume it is in the same place.
(Assignee)

Comment 1

13 years ago
Created attachment 187339 [details] [diff] [review]
Fix

AFAICS this one-line fix is enough to fix the optimizer issue that caused the
bug. But since the bug was in Rhino since the first public release and survived
all the changes during last 5 years I am very reluctant to commit the fix
without really good testing.
(Assignee)

Comment 2

13 years ago
I committed the patch.
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED
(Reporter)

Comment 3

13 years ago
(In reply to comment #2)

I still have some infinite loops when I set 
Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME true and I use the feature, both 
in the compiler and at runtime. Should this go in a separate bug report?
(Assignee)

Comment 4

13 years ago
(In reply to comment #3)
> (In reply to comment #2)
> 
> I still have some infinite loops when I set 
> Context.FEATURE_MEMBER_EXPR_AS_FUNCTION_NAME true and I use the feature, both 
> in the compiler and at runtime. Should this go in a separate bug report?

Do you see this with latest CVS tip as well? It contains a few fixes in this
area. If yes, then file a bug indeed.
You need to log in before you can comment on or make changes to this bug.