United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7160610 Unknown Native Code compilation issue.
JDK-7160610 : Unknown Native Code compilation issue.

Details
Type:
Bug
Submit Date:
2012-04-11
Status:
Resolved
Updated Date:
2013-09-04
Project Name:
JDK
Resolved Date:
2012-05-16
Component:
hotspot
OS:
windows_7
Sub-Component:
compiler
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:
hs24 (b10)

Related Reports
Backport:
Backport:
Backport:

Sub Tasks

Description
FULL PRODUCT VERSION :
1.7.0_02

FULL OS VERSION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
When I obfuscate my code a certain portion of it creates an error. I decompiled it and tested out the code by compiling normally and there was the same issue so I know it was not the obfuscators fault.

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just execute the method given below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Should just execute without any errors.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (vectornode.cpp:105), pid=2576, tid=3152
#  Error: ShouldNotReachHere()
#
# JRE version: 7.0_02-b13
# Java VM: Java HotSpot(TM) 64-Bit Server VM (22.0-b10 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#

---------------  T H R E A D  ---------------

Current thread (0x0000000006207000):  JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=3152, stack(0x00000000071c0000,0x00000000072c0000)]

Stack: [0x00000000071c0000,0x00000000072c0000]

Current CompileTask:
C2:    413    1 %           org.qatide.jbco.util.ArrayTest::randomizeBackground @ 10 (258 bytes)


---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x00000000062d6800 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=6708, stack(0x00000000076e0000,0x00000000077e0000)]
  0x0000000006208800 JavaThread "Service Thread" daemon [_thread_blocked, id=6368, stack(0x00000000073a0000,0x00000000074a0000)]
=>0x0000000006207000 JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=3152, stack(0x00000000071c0000,0x00000000072c0000)]
  0x00000000061fa000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=6712, stack(0x0000000006fd0000,0x00000000070d0000)]
  0x00000000061f7000 JavaThread "Attach Listener" daemon [_thread_blocked, id=4376, stack(0x0000000006da0000,0x0000000006ea0000)]
  0x00000000061f2000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3208, stack(0x0000000006880000,0x0000000006980000)]
  0x00000000021b2800 JavaThread "Finalizer" daemon [_thread_blocked, id=2872, stack(0x0000000006bd0000,0x0000000006cd0000)]
  0x00000000021b1000 JavaThread "Reference Handler" daemon [_thread_blocked, id=6188, stack(0x0000000006a20000,0x0000000006b20000)]
  0x00000000022ac000 JavaThread "main" [_thread_in_Java, id=1588, stack(0x0000000002370000,0x0000000002470000)]

Other Threads:
  0x00000000021a6000 VMThread [stack: 0x0000000006740000,0x0000000006840000] [id=5648]
  0x0000000006215800 WatcherThread [stack: 0x00000000074d0000,0x00000000075d0000] [id=4692]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 PSYoungGen      total 28224K, used 1451K [0x00000000e0760000, 0x00000000e26e0000, 0x0000000100000000)
  eden space 24192K, 6% used [0x00000000e0760000,0x00000000e08caf70,0x00000000e1f00000)
  from space 4032K, 0% used [0x00000000e22f0000,0x00000000e22f0000,0x00000000e26e0000)
  to   space 4032K, 0% used [0x00000000e1f00000,0x00000000e1f00000,0x00000000e22f0000)
 PSOldGen        total 64576K, used 0K [0x00000000a1600000, 0x00000000a5510000, 0x00000000e0760000)
  object space 64576K, 0% used [0x00000000a1600000,0x00000000a1600000,0x00000000a5510000)
 PSPermGen       total 21248K, used 2949K [0x000000009c400000, 0x000000009d8c0000, 0x00000000a1600000)
  object space 21248K, 13% used [0x000000009c400000,0x000000009c6e1588,0x000000009d8c0000)

Code Cache  [0x0000000002470000, 0x00000000026e0000, 0x0000000005470000)
 total_blobs=187 nmethods=2 adapters=138 free_code_cache=48767Kb largest_free_block=49918976

Dynamic libraries:
0x000000013fc20000 - 0x000000013fc53000 	C:\Program Files\Java\jdk1.7.0_02\bin\java.exe
0x0000000077690000 - 0x0000000077839000 	C:\Windows\SYSTEM32\ntdll.dll
0x0000000077410000 - 0x000000007752f000 	C:\Windows\system32\kernel32.dll
0x000007fefdd70000 - 0x000007fefdddc000 	C:\Windows\system32\KERNELBASE.dll
0x000007fefe610000 - 0x000007fefe6eb000 	C:\Windows\system32\ADVAPI32.dll
0x000007fefe430000 - 0x000007fefe4cf000 	C:\Windows\system32\msvcrt.dll
0x000007fefe920000 - 0x000007fefe93f000 	C:\Windows\SYSTEM32\sechost.dll
0x000007fefe4e0000 - 0x000007fefe60d000 	C:\Windows\system32\RPCRT4.dll
0x0000000076fb0000 - 0x00000000770aa000 	C:\Windows\system32\USER32.dll
0x000007fefe800000 - 0x000007fefe867000 	C:\Windows\system32\GDI32.dll
0x000007fefdfe0000 - 0x000007fefdfee000 	C:\Windows\system32\LPK.dll
0x000007fefe250000 - 0x000007fefe319000 	C:\Windows\system32\USP10.dll
0x000007fefc570000 - 0x000007fefc764000 	C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_fa396087175ac9ac\COMCTL32.dll
0x000007fefdf60000 - 0x000007fefdfd1000 	C:\Windows\system32\SHLWAPI.dll
0x000007fefe400000 - 0x000007fefe42e000 	C:\Windows\system32\IMM32.DLL
0x000007fefe6f0000 - 0x000007fefe7f9000 	C:\Windows\system32\MSCTF.dll
0x00000000735a0000 - 0x0000000073671000 	C:\Program Files\Java\jdk1.7.0_02\jre\bin\msvcr100.dll
0x000000006d210000 - 0x000000006d8ea000 	C:\Program Files\Java\jdk1.7.0_02\jre\bin\server\jvm.dll
0x000007fefa630000 - 0x000007fefa639000 	C:\Windows\system32\WSOCK32.dll
0x000007fefe870000 - 0x000007fefe8bd000 	C:\Windows\system32\WS2_32.dll
0x000007fefe4d0000 - 0x000007fefe4d8000 	C:\Windows\system32\NSI.dll
0x000007fefbba0000 - 0x000007fefbbdb000 	C:\Windows\system32\WINMM.dll
0x0000000077860000 - 0x0000000077867000 	C:\Windows\system32\PSAPI.DLL
0x0000000073920000 - 0x000000007392f000 	C:\Program Files\Java\jdk1.7.0_02\jre\bin\verify.dll
0x0000000073870000 - 0x0000000073898000 	C:\Program Files\Java\jdk1.7.0_02\jre\bin\java.dll
0x0000000073850000 - 0x0000000073865000 	C:\Program Files\Java\jdk1.7.0_02\jre\bin\zip.dll
0x000007fefb730000 - 0x000007fefb740000 	C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 11.0\bin\breakgen64.dll
0x0000000073810000 - 0x0000000073829000 	C:\Program Files\Java\jdk1.7.0_02\jre\bin\net.dll
0x000007fefd340000 - 0x000007fefd395000 	C:\Windows\system32\mswsock.dll
0x000007fefd330000 - 0x000007fefd337000 	C:\Windows\System32\wship6.dll

VM Arguments:
jvm_args: -Didea.launcher.port=7535 -Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 11.0\bin -Dfile.encoding=UTF-8
java_command: com.intellij.rt.execution.application.AppMain org.qatide.jbco.JavaBytecodeObfuscator
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 11.0\bin\..\.\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Trend Micro\AMSP;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Java\jdk1.6.0_25\bin\;c:\program files (x86)\jetbrains\intellij idea community edition 11.0\jre\jre\bin
USERNAME=Scott
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows 7 , 64 bit Build 7601 Service Pack 1

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 42 stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

Memory: 4k page, physical 6194316k(3244640k free), swap 12386780k(8891900k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (22.0-b10) for windows-amd64 JRE (1.7.0_02-b13), built on Nov 17 2011 13:51:15 by "java_re" with unknown MS VC++:1600

time: Wed Apr 11 08:00:39 2012
elapsed time: 0 seconds


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class ArrayTest {
	private static final byte[] $BYTE_ARRAY = new byte[7];
	private static int[] anIntArray1190 = new int[32768];
	private static int[] anIntArray1191 = new int[32768];

	public static void main(String args[])
	{
		int i = 256;
		for(int j = $BYTE_ARRAY[2]; j < anIntArray1190.length; j++)
		{
			anIntArray1190[j] = $BYTE_ARRAY[2];
		}

		for(int k = $BYTE_ARRAY[2]; (k ^ $BYTE_ARRAY[1]) > -5001; k++)
		{
			int i1 = (int)(Math.random() * 128D * (double)i);
			anIntArray1190[i1] = (int)(Math.random() * 256D);
		}

		System.out.println(3);
		for(int l = $BYTE_ARRAY[2]; (l ^ $BYTE_ARRAY[1]) > -21; l++)
		{
			for(int j1 = $BYTE_ARRAY[0]; j1 < i + -$BYTE_ARRAY[0]; j1++)
			{
				for(int k1 = $BYTE_ARRAY[0]; (k1 ^ $BYTE_ARRAY[1]) > -128; k1++)
				{
					int l1 = k1 - -(j1 << 0x26cb6487);
					anIntArray1191[l1] = (anIntArray1190[l1 + -$BYTE_ARRAY[0]] - -anIntArray1190[l1 - -$BYTE_ARRAY[0]] - -anIntArray1190[-128 + l1] - -anIntArray1190[128 + l1]) / $BYTE_ARRAY[6];
				}

			}

			int ai[] = anIntArray1190;
			anIntArray1190 = anIntArray1191;
			anIntArray1191 = ai;
		}

	}

	static {
		$BYTE_ARRAY[6] = 4;
		$BYTE_ARRAY[5] = 5;
		$BYTE_ARRAY[4] = 3;
		$BYTE_ARRAY[3] = 2;
		$BYTE_ARRAY[2] = 0;
		$BYTE_ARRAY[1] = -1;
		$BYTE_ARRAY[0] = 1;
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Added printlines inside the loops to see where it stops and it worked.

                                    

Comments
EVALUATION

The problem is caused by conflict between types of init value (BYTE) and stored value (Int):

control	 504	CountedLoop	===  504  304  170  [[ 459  460  461  462  464  465  479  482  485  503  504  390  507  155  345  311  348  237  391  401  398 ]] inner stride: 16 main of N504  Type:control !orig=[415],[358],[319],[238],[216],[103] !jvms: ArrayTest::main @ bci:18
byte	 485	LoadB	===  504  7  119  [[ 459  460  461  462  464  465  479  482  345  348  155  311  401  398  391  390 ]]  @byte[int:>=0]:BotPTR:exact+any *, idx=7;  Type:byte !orig=[404],[351],[314],[120] !jvms: ArrayTest::main @ bci:26

int	 155	StoreI	===  504  311  153  485  [[ 294  507 ]]  @int[int:>=0]:BotPTR:exact+any *, idx=8;  Memory: @int[int:>=0]:NotNull:exact+any *, idx=8; !orig=[325] !jvms: ArrayTest::main @ bci:27

When vector is constructed it asked for supported combination of size and type in SuperWord::vector_opd() and if operand is in Loop it uses operand's type instead of type of vector's element.

The test passed in jdk7u4 because LoadB is moved outside the loop.

We should always use vector's element type.
                                     
2012-04-12
WORK AROUND

Add flag -XX:-UseSuperWord.
                                     
2012-04-12
SUGGESTED FIX

src/share/vm/opto/superword.cpp
@@ -1222,10 +1222,8 @@
     }
     assert(!opd->is_VectorStore(), "such vector is not expected here");
     // Convert scalar input to vector. Use p0's type because it's container
-    // maybe smaller than the operand's container.
-    const Type* opd_t = velt_type(!in_bb(opd) ? p0 : opd);
-    const Type* p0_t  = velt_type(p0);
-    if (p0_t->higher_equal(opd_t)) opd_t = p0_t;
+    // should match the operand's vector container.
+    const Type* opd_t = velt_type(p0);
     VectorNode* vn    = VectorNode::scalar2vector(_phase->C, opd, vlen, opd_t);
 
     _phase->_igvn.register_new_node_with_optimizer(vn);
                                     
2012-04-12
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/rev/dc682d9431f3
                                     
2012-05-08
EVALUATION

http://hg.openjdk.java.net/hsx/hotspot-rt/hotspot/rev/dc682d9431f3
                                     
2012-05-12
EVALUATION

http://hg.openjdk.java.net/lambda/lambda/hotspot/rev/dc682d9431f3
                                     
2012-06-29



Hardware and Software, Engineered to Work Together