Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356002 - VerifyError "Inconsistent stackmap frames" for switch-string statement with nested for-loop
Summary: VerifyError "Inconsistent stackmap frames" for switch-string statement with n...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 3.6.2+J7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-27 09:05 EDT by Andre Bargull CLA
Modified: 2012-12-17 08:51 EST (History)
4 users (show)

See Also:
daniel_megert: pmc_approved+
jarthana: review+


Attachments
Proposed fix + regression tests (6.54 KB, patch)
2011-08-29 10:35 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression tests (3.7.x) (7.43 KB, patch)
2011-08-29 13:24 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Bargull CLA 2011-08-27 09:05:54 EDT
Build Identifier: M20110825-0847

Executing the following test case will result in a VerifyError "Inconsistent stackmap frames at branch target".

Environment:
- Eclipse 3.7.1 (M20110825-0847)
- JDK7

Stacktrace:
---
Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 42 in method example.Testcase.normalize()V at offset 39
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
	at java.lang.Class.getMethod0(Class.java:2685)
	at java.lang.Class.getMethod(Class.java:1620)
	at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:484)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:476)
---

---
public class Testcase {
    public static void main(String args[]) { }

    public static void normalize() {
        int k;
        switch ("") {
        case "":
            for (int j = 0; j < 0;) { break; }
            k = 0;
        }
    }
}
---

Reproducible: Always
Comment 1 Andre Bargull CLA 2011-08-27 12:56:49 EDT
Simplified test case:
---
public static void normalize0() {
    switch ("") {
    default:
    {
        int j = 0;
        if (j < 0) ;
    }
        return;
    }
}
---
Comment 2 Olivier Thomann CLA 2011-08-28 19:16:28 EDT
Reproduced with latest in 3.7.maintenance.
I am investigating. This might be a candidate for 3.7.1 as it is a verify error. Verify errors are severe issues.
Comment 3 Olivier Thomann CLA 2011-08-29 10:35:20 EDT
Created attachment 202328 [details]
Proposed fix + regression tests

Two things:
1) The secret local must be created before the switch's statements are resolved. If one of them is a block that defines more locals, the locals overlap and it returns a VerifyError.
2) When there is no cases statements, the value generated by the invoke hashcode call must be popped from the stack. Otherwise we "keep" a value on the stack after the switch statement is done. This tends to generate bigger stack map frames.
Comment 4 Olivier Thomann CLA 2011-08-29 10:37:15 EDT
Daniel, pmc approval is required for 3.7.1 release.
Jay, please review asap.

Thanks.
Comment 5 Dani Megert CLA 2011-08-29 10:56:12 EDT
+1. This needs to be fixed for 3.7.1.
Comment 6 Jay Arthanareeswaran CLA 2011-08-29 12:58:28 EDT
Patch looks good to me
Comment 7 Olivier Thomann CLA 2011-08-29 13:24:21 EDT
Created attachment 202347 [details]
Proposed fix + regression tests (3.7.x)

Same patch for 3.7.1 where the error message is slightly different from 3.8.
Comment 8 Olivier Thomann CLA 2011-08-29 13:24:47 EDT
This affects the tests only. Not the code itself.
Comment 9 Olivier Thomann CLA 2011-08-30 13:32:02 EDT
Released for 3.7.1RC3 and 3.8M2.
Comment 10 Jay Arthanareeswaran CLA 2011-09-05 05:43:38 EDT
Verified for 3.7.1 with build M20110831-1030.
Comment 11 Ayushman Jain CLA 2011-09-14 12:27:46 EDT
Verified for 3.8M2 using build I20110911-2000.
Comment 12 Jay Arthanareeswaran CLA 2012-12-17 08:49:14 EST
For the record, this fix was also released in R3_6_maintenance_Java7 via commit 85bffda76894743d59fada2a6e096ed63bf7a359