Bug 5268 - VerifyError when running app
Summary: VerifyError when running app
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-10-25 19:04 EDT by Jed Anderson CLA
Modified: 2002-01-11 09:22 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jed Anderson CLA 2001-10-25 19:04:40 EDT
PRODUCT VERSION:
203

DESCRIPTION:
I did a copy to clipboard operation in the SwtStyledTextUseCase when I got
the exception shown below. 

java.lang.VerifyError: (class: org/eclipse/swt/custom/StyledText$RTFWriter, 
method: write signature: (Ljava/lang/String;II)V) Inconsistent stack height 1 !
= 0
	at org.eclipse.swt.custom.StyledText.copy(StyledText.java:1169)
	at org.eclipse.swt.custom.StyledText.invokeAction(StyledText.java:4613)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:4297)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:4267)
	at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:3989)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:54)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:645)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1359)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1160)
	at org.eclipse.swt.examples.exampleframework.SwtExample.run
(SwtExample.java:186)
	at org.eclipse.swt.examples.tests.SwtStyledTextUseCase.main
(SwtStyledTextUseCase.java:631)
Exception in thread "main" 

NOTES:

The bytecodes for the guilty method are:
Method void write(java.lang.String, int, int)
   0 iload_2			=> stack height = 1
   1 istore 4 			=> stack height = 0
   3 goto 41			=> stack height = 0
   6 aload_1			=> stack height = 1
   7 iload 4			=> stack height = 2
   9 invokevirtual #224 <Method char charAt(int)>			=> 
stack height = 1
  12 istore 5			=> stack height = 0
  14 iload 5			=> stack height = 1
  16 bipush 125			=> stack height = 2
  18 if_icmpeq 47			=> stack height = 0
  21 iload 5			=> stack height = 1
  23 bipush 123			=> stack height = 2
  25 if_icmpeq 47			=> stack height = 0
  28 iload 5			=> stack height = 1
  30 bipush 92			=> stack height = 2
  32 if_icmpne 38			=> stack height = 0
  35 goto 47			=> stack height = 0
  38 iinc 4 1			=> stack height = 0
  41 iload 4			=> stack height = 1
  43 iload_3			=> stack height = 2
  44 if_icmplt 6			=> stack height = 0
  47 iload 4			=> stack height = 1
  49 iload_3			=> stack height = 2
  50 if_icmpne 66			=> stack height = 0
  53 aload_0			=> stack height = 1
  54 aload_1			=> stack height = 2
  55 iload_2			=> stack height = 3
  56 iload_3			=> stack height = 4
  57 invokevirtual #122 <Method java.lang.String substring(int, int)>		
	=> stack height = 2
  60 invokevirtual #63 <Method void write(java.lang.String)>		
	=> stack height = 0
  63 goto 154			=> stack height = 0
  66 iload_3			=> stack height = 1
  67 iload_2			=> stack height = 2
  68 isub			=> stack height = 1
  69 newarray char			=> stack height = 1
  71 astore 5			=> stack height = 0
  73 aload_1			=> stack height = 1
  74 iload_2			=> stack height = 2
  75 iload_3			=> stack height = 3
  76 aload 5			=> stack height = 4
  78 iconst_0			=> stack height = 5
  79 invokevirtual #228 <Method void getChars(int, int, char[], int)>		
	=> stack height = 0
  82 iconst_0			=> stack height = 1
  83 istore 4			=> stack height = 0
  85 goto 146			=> stack height = 0
  88 aload 5			=> stack height = 1
  90 iload 4			=> stack height = 2
  92 caload			=> stack height = 1
  93 lookupswitch 3: default=134			=> stack height = 0
	   92: 128
	  123: 128
	  125: 93
 128 aload_0			=> stack height = 1
 129 ldc #230 <String "\">			=> stack height = 2
 131 invokevirtual #63 <Method void write(java.lang.String)>		
	=> stack height = 0
 134 aload_0			=> stack height = 1
 135 aload 5			=> stack height = 2
 137 iload 4			=> stack height = 3
 139 caload			=> stack height = 2
 140 invokevirtual #233 <Method void write(char)>			=> 
stack height = 0
 143 iinc 4 1			=> stack height = 0
 146 iload 4			=> stack height = 1
 148 aload 5			=> stack height = 2
 150 arraylength			=> stack height = 2
 151 if_icmplt 88			=> stack height = 0
 154 return			=> stack height = 0

	The jump 93 inside the lookupswitch is wrong. It should be 128 like 
the others.

	This is really weird. I use the jdtcore.jar from the 203 build to 
recompile the source you provided with the workspace and I could get the same 
bytecodes. I have:
  93 lookupswitch 3: default=134			=> stack height = 0
	   92: 128
	  123: 128
	  125: 128
	Which is the expected answer.
	If I recompile the project org.eclipse.swt doing a full build, I can 
reproduce the problem. If I take all the sources according to the classpath and 
use a batch compilation, I don't
	get it. I need to find out a reproducable test case that I can debug.

OT (10/10/2001 6:51:00 PM)
	After looking at the problem, I suspect a resize of the code stream 
byte array to be responsible of this problem. The last offset for the case 
label is offsetted by one
	compare to its right position.

OT (10/10/2001 7:20:30 PM)
	The method writeSignedWord was wrong. If a resize of the byte array 
was necessary while writing one of these four bytes, the byte was actually 
written offsetted by one, because the currentOffset was already incremented. 
currentOffset - 1 is the right position. So according to the size of the byte 
array when the StyledText class is compiled, we can hit or not the problem. 
	Released in HEAD 2.0
Comment 1 Philipe Mulet CLA 2001-10-26 07:04:23 EDT
Fixed and backported to 1.0 patch
Comment 2 Jerome Lanneluc CLA 2001-12-05 06:28:48 EST
Fixed in 1.0 Rollup 139