Bug 157247 - [1.6] [compiler] VerifyError with StackMap frames when no local variable attributes are generated
Summary: [1.6] [compiler] VerifyError with StackMap frames when no local variable attr...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-13 20:10 EDT by Olivier Thomann CLA
Modified: 2006-09-19 00:33 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (5.41 KB, patch)
2006-09-13 20:10 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix for 3.2 maintenance branch (5.42 KB, patch)
2006-09-13 20:40 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix for head (5.41 KB, patch)
2006-09-13 20:47 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression tests for 3.2 maintenance branch (1.68 KB, patch)
2006-09-13 20:47 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression tests for head (1.67 KB, patch)
2006-09-13 20:48 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 Olivier Thomann CLA 2006-09-13 20:10:27 EDT
When using the compiler without the -g option, only lines and source attributes are generated.
This can result in VerifyError.
For example, running the following class with a JDK6 VM:
java -XX:-FailOverToOldVerifier -Xverify:all X

will fail with:
Exception in thread "main" java.lang.VerifyError: Stack map does not match the one at exception handler 9 in method X.main([Ljava/lang/String;)V at offset 0

Test case:

public class X {

	public static void main(String[] args) {
		String errorMessage;
		try {
			foo();
			errorMessage = "No exception thrown";
		} catch (Exception e) {
			e.printStackTrace();
			errorMessage = "Exception thrown";
		}
		System.out.println(errorMessage);
	}
	
	public static void foo() {
		throw new NullPointerException();
	}
}
Comment 1 Olivier Thomann CLA 2006-09-13 20:10:54 EDT
Created attachment 50102 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2006-09-13 20:40:52 EDT
Created attachment 50105 [details]
Proposed fix for 3.2 maintenance branch
Comment 3 Olivier Thomann CLA 2006-09-13 20:47:17 EDT
Created attachment 50106 [details]
Proposed fix for head
Comment 4 Olivier Thomann CLA 2006-09-13 20:47:40 EDT
Created attachment 50107 [details]
Regression tests for 3.2 maintenance branch
Comment 5 Olivier Thomann CLA 2006-09-13 20:48:03 EDT
Created attachment 50108 [details]
Regression tests for head
Comment 6 Philipe Mulet CLA 2006-09-14 03:47:25 EDT
For performance reason, instead of:

if (((this.generateAttributes & ClassFileConstants.ATTR_VARS) == 0)
	&& ((this.generateAttributes & ClassFileConstants.ATTR_STACK_MAP) == 0))

you should write:

if ((this.generateAttributes
        & (ClassFileConstants.ATTR_VARS|ClassFileConstants.ATTR_STACK_MAP)) == 0)
Comment 7 Philipe Mulet CLA 2006-09-14 03:49:19 EDT
For 3.2maintenance, pls hold on the fix until I ping the rest of PMC (need escalation at this stage).
Comment 8 Philipe Mulet CLA 2006-09-14 04:23:22 EDT
Other than perf comment 6, the proposed patch looks good to me.
Comment 9 Philipe Mulet CLA 2006-09-14 12:19:48 EDT
pmc approved fixing it for 3.2.1
Comment 10 Olivier Thomann CLA 2006-09-14 15:37:41 EDT
Released for 3.2.1.
Released for 3.3M2.
Regression test added in org.eclipse.jdt.core.tests.compiler.regression.StackMapAttributeTest#test022.
Comment 11 Frederic Fusier CLA 2006-09-18 13:33:34 EDT
Verified for 3.2.1 using ecj.jar built from M20060915-1045
Comment 12 Maxime Daniel CLA 2006-09-19 00:33:21 EDT
Verified for 3.3 M2 using build I20060918-0010.
I used Eclipse itself, with all optional generation boxes unchecked in the compiler preferences (yields the expected error with 3.2).