Bug 177623 - [1.6][compiler] Stackmap frames generation should be protected against invalid code
Summary: [1.6][compiler] Stackmap frames generation should be protected against invali...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-15 14:58 EDT by Olivier Thomann CLA
Modified: 2007-03-20 11:40 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (154.22 KB, patch)
2007-03-16 11:03 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 2007-03-15 14:58:31 EDT
When invalid code is getting compiled, the stack map frame generation should not fail with NPE.
java.lang.NullPointerException	at org.eclipse.jdt.internal.compiler.codegen.StackMapFrameCodeStream.getfield(StackMapFrameCodeStream.java:799)	at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.generateReadSequence(QualifiedNameReference.java:653)	at org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference.generateCode(QualifiedNameReference.java:386)	at org.eclipse.jdt.internal.compiler.ast.ReturnStatement.generateCode(ReturnStatement.java:126)	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:229)	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.generateCode(AbstractMethodDeclaration.java:176)	

It should protect itself against this and the code should fail at runtime with a VerifyError since the code generation produced invalid bytecodes.
Comment 1 Olivier Thomann CLA 2007-03-15 14:59:17 EDT
Steps to reproduce:
change line 595 in QualifiedNameReference with:
if ((needValue && !lastFieldBinding.isStatic())) {

and execute GenericTypeTest#test1116 in 1.6 mode.
Comment 2 Olivier Thomann CLA 2007-03-16 11:03:05 EDT
Created attachment 61108 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2007-03-16 11:03:44 EDT
Released for 3.3M6.
Comment 4 Frederic Fusier CLA 2007-03-20 11:40:55 EDT
Verified for 3.3 M6 using I20070319-1800.