Closed Bug 695354 Opened 13 years ago Closed 13 years ago

try/finally bad opcode in R3

Categories

(Rhino Graveyard :: Compiler, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: northerncoder, Unassigned)

References

Details

Attachments

(3 files)

I upgraded my embedded Rhino to 1.7R3 from 1.7R1
Tried to compile scripts that contained try/finally blocks that were fine with 1.7R1 and also tried to execute the following script in the Rhino shell:
var x = 1;
try {
x = 2;
} catch(err) {
x = 3;
} finally {
x = 4;
}

In all cases, scripts with a try/finally block were resulting in the following exception:

Caused by: java.lang.IllegalArgumentException: bad opcode
       at org.mozilla.classfile.ClassFileWriter
$StackMapTable.execute(ClassFileWriter.java:2271)
       at org.mozilla.classfile.ClassFileWriter
$StackMapTable.executeBlock(ClassFileWriter.java:1739)
       at org.mozilla.classfile.ClassFileWriter
$StackMapTable.executeWorkList(ClassFileWriter.java:1719)
       at org.mozilla.classfile.ClassFileWriter
$StackMapTable.verify(ClassFileWriter.java:1657)
       at org.mozilla.classfile.ClassFileWriter
$StackMapTable.generate(ClassFileWriter.java:1503)
       at
org.mozilla.classfile.ClassFileWriter.stopMethod(ClassFileWriter.java:
322)
       at
org.mozilla.javascript.optimizer.BodyCodegen.generateBodyCode(Codegen.java:
1399)
       at org.mozilla.javascript.optimizer.Codegen.generateCode(Codegen.java:
341)
       at
org.mozilla.javascript.optimizer.Codegen.compileToClassFile(Codegen.java:
196)
       at org.mozilla.javascript.optimizer.Codegen.compile(Codegen.java:105)
       at org.mozilla.javascript.Context.compileImpl(Context.java:2430)
       at org.mozilla.javascript.Context.compileString(Context.java:1367)
       at org.mozilla.javascript.Context.compileString(Context.java:1356)
       at
org.mozilla.javascript.tools.shell.Main.loadScriptFromSource(Main.java:
561)
       at
org.mozilla.javascript.tools.shell.Main.processFileSecure(Main.java:
546)
       at org.mozilla.javascript.tools.shell.Main.processFile(Main.java:507)
       at org.mozilla.javascript.tools.shell.Global.load(Global.java:282)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)


With 1.7R1, this exception did not occur.
Your sample code works for me with Rhino 1.7R3. What Java implementation/version are you using?
I using jdk1.6.0_16 and DO need to use 1.6.
However, I just tried with jdk1.5.0_11 and don't see the exception.
Severity: normal → blocker
Where did you get your copy of Rhino from? Did you build yourself or download a binary distribution? If you built Rhino yourself make sure you don't have any local changes and try makeing a clean build:

    ant clean jar

Are you running with any special flags? I guess this must be some local issue, otherwise there would be more reports. 

Setting importance to normal until we find out whether it's an actual issue with Rhino.
Severity: blocker → normal
Attached file eclipse project file
Problem occurs when I compile rhino with the Compiler Compliance Level set to 1.6.
I do not get the error when I compile with the level set to 1.5.
To clarify, I am not using the and build files to compile and run.

I've attached my eclipse project, classpath and run configuration files.
That js-14.jar in your classpath looks fishy. Can you check the timestamp how old that file is, and remove it from both disk and classpath?
Removed it from both disk and classpath...still getting the exception.
I downloaded the rhino jar from http://www.mozilla.org/rhino/download.html.
Using the link: ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3.zip

The date on all the files in the jar is "May  9  2011", including the js-14.jar.
I see now that the WIDE instructions that triggers this error is actually used by ClassFileWriter internally. Hope to have a patch in git that you can try soon.
Tom and/or Andy, can you please check if the "fix-stackmap" branch here fixes the problem for you:

https://github.com/mozilla/rhino/tree/fix-stackmap

Since I still can't reproduce the problem locally it would also be great if you could make sure you still see the problem with current master branch.
Preliminary tests show that "fix-stackmap" works, at least with the test case provided in Bug #710027.
fix-stackmap branch passes our tests, many thanks!
Thanks! I merged the change to both master and rhino_1_8 branch. 

https://github.com/mozilla/rhino/commit/f7f63f18a0c34de713036dcbd4e305e1f3ce878c

(Also deleted fix-stackmap branch from github.)
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: