-
Bug
-
Resolution: Incomplete
-
P3
-
8
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b128)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ip-172-31-38-240.us-west-2.compute.internal 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon Jun 17 15:54:20 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
It is AWS "m1.xlarge" instance - with 4 core and 12 GB RAM
A DESCRIPTION OF THE PROBLEM :
Test spec:
0. JS script is compiled (once) & invoked by Invocable.invokeFunction() with various inputs multiple times.
1. 600+ line of JavaScript-code, which has ~20+ functions and encapsulated using JavaScript object constructors.
Example (which illustrates the common template on our js file):
Legacy Style Script:
function execute(someParameter){
return new complexLogic(someParameter).do();
}
function complexLogic(someParameter){
this.parameter=someParameter;
this.logic1 = function() { /*logic goes here*/}
this.logic2 = function() { /*logic goes here*/}
..
..
this.logicN = function() { /*logic goes here*/}
this.do = function(){
var finalData={};
finalData.Attribute1 = this.logic1();
finalData.Attribute2 = this.logic2();
..
..
finalData.AttributeM = this.logicN();
return finalData;
}
}
JSLint Complaint Script (where we addressed all the issues reported by JSLint):
function execute(someParameter){
return do(getComplexLogic(someParameter));
}
function getComplexLogic(someParameter){
return {
parameter=someParameter,
logic1 = function() { /*logic goes here*/}
logic2 = function() { /*logic goes here*/}
..
..
logicN = function() { /*logic goes here*/}
}
}
function do(container) {
var finalData={};
finalData.Attribute1 = container .logic1();
finalData.Attribute2 = container .logic2();
..
..
finalData.AttributeM = container .logicN();
return finalData;
}
2. Nashorn always invokes the function execute() with appropriate inputs passed on to it. Inside execute(), we construct the object and we call the low level functions encapsulated inside the object.
3. We made 300 distinct set of scripts (each script function has distinct name without any conflicts, the sorucecode is more or less same).
1st Use case (aka Shared ScriptEngine): Load all these 300 distinct set of scripts into single ScriptEngine instance & 2 parallel threads invokes the js functions one by one with corresponding ScriptEngine instance for set of inputs, repeatedly - in infinite loop until the process crashes.
2nd Use case (aka Isolated ScriptEngine): Load these 300 distinct set of scripts into its own independent ScriptEngine instance & 2 parallel threads invokes the js functions one by one with corresponding ScriptEngine instance for set of inputs, repeatedly -in infinite loop until the process crashes.
Observations:
1. Round-1:
a. Both test case failed crashed immediately, with following error.
Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
CodeCache: size=245760Kb used=243668Kb max_used=244353Kb free=2091Kb
bounds [0x00007fdb55000000, 0x00007fdb64000000, 0x00007fdb64000000]
total_blobs=45680 nmethods=45250 adapters=342
compilation: enabled
b. Workaround: To delay this problem we supplied -XX:ReservedCodeCacheSize=2g (maximum possible value for Linux JVM).
New JVM parameters are -Xms6g -XX:ReservedCodeCacheSize=2g -XX:+UseCodeCacheFlushing
2. Revised Boundary test result:
a. 1st Use case â Shared Script Engine: Stable for 200 distinct set of scripts. Failed when we test for more than 200.
b. 2nd Use case â Isolated Script Engine: Stable for 100 distinct set of scripts. Failed when we test for more than 100.
3. Failure:
a. We no longer receive âCodeCache is full. Compiler has been disabled.â Exception but it crashed with following error, we noticed that there is a enough heap-memory during this error. We also noticed that the NonHeap memory is constantly growing before it get crashed, but heap memory is under control.
Exception in thread "pool-1-thread-2"
java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z132(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$DMH/2033961110.invokeSpecial_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1408023090.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at java.lang.invoke.LambdaForm$DMH/70889489.invokeStatic_LLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/92670580.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/970100220.invokeSpecial_LLLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NFI/85938268.invoke_LLLLLL_L(LambdaForm$NFI)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/265919263.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1503490613.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1912616525.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
Exception in thread "pool-1-thread-1" java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/677211270.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/155694314.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1945608681.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/302887348.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/810806242.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at java.lang.invoke.LambdaForm$DMH/1557401603.invokeStatic_LLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/2093777852.invokeExact_MT(LambdaForm$MH)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
REGRESSION. Last worked in version 7u51
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Same Java-code
Same JavaScript
When we compile & execute with jre.1.7.X.X it is working (though the performance is bad) fine without any issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should work without any exception.
ACTUAL -
In Java8 we are getting bellow exception:
Exception in thread "pool-1-thread-2"
java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z132(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$DMH/2033961110.invokeSpecial_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1408023090.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at java.lang.invoke.LambdaForm$DMH/70889489.invokeStatic_LLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/92670580.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/970100220.invokeSpecial_LLLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NFI/85938268.invoke_LLLLLL_L(LambdaForm$NFI)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/265919263.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1503490613.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1912616525.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
Exception in thread "pool-1-thread-1" java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/677211270.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/155694314.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1945608681.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/302887348.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/810806242.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at java.lang.invoke.LambdaForm$DMH/1557401603.invokeStatic_LLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/2093777852.invokeExact_MT(LambdaForm$MH)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "pool-1-thread-2"
java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z132(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$DMH/2033961110.invokeSpecial_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1408023090.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at java.lang.invoke.LambdaForm$DMH/70889489.invokeStatic_LLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/92670580.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/970100220.invokeSpecial_LLLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NFI/85938268.invoke_LLLLLL_L(LambdaForm$NFI)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/265919263.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1503490613.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1912616525.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
Exception in thread "pool-1-thread-1" java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/677211270.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/155694314.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1945608681.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/302887348.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/810806242.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at java.lang.invoke.LambdaForm$DMH/1557401603.invokeStatic_LLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/2093777852.invokeExact_MT(LambdaForm$MH)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.script.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Reproducible {
class Script {
private ScriptEngine engine;
public Invocable invocable;
public Script(ScriptEngine engine) {
this.engine = engine;
this.invocable = (Invocable)engine;
}
}
HashMap<Integer, Script> scripts = new HashMap<Integer, Script> ();
public void init(int numberOfInstances) throws FileNotFoundException, ScriptException {
for(int index=0; index<numberOfInstances; index++) {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
FileReader fileReader = new FileReader("/sample_" + index + ".js" );
CompiledScript script = ((Compilable)engine).compile(fileReader);
script.eval();
scripts.put(index, new Script(engine));
}
}
public void execute(Object[] inputs) throws ScriptException, NoSuchMethodException {
while(true) {
for(Object input : inputs) {
for(Script script : scripts.values()) {
script.invocable.invokeFunction("execute", input);
}
}
}
}
}
class Startup {
public static void Main() throws FileNotFoundException, ScriptException {
Reproducible reproducible = new Reproducible();
reproducible.init(200);
ExecutorService executor = Executors.newFixedThreadPool(2);
for(int i=0; i<2; i++){
Runnable worker = new Delegate(reproducible);
executor.execute(worker);
}
executor.shutdown();
while(!executor.isTerminated());
System.out.println("Bye Bye!");
}
}
class Delegate implements Runnable {
private final Reproducible reproducible;
public Delegate(Reproducible reproducible) {
this.reproducible = reproducible;
}
private Object[] getInputs() {
//The actutal implementaion to get some data from somewhere
return new Object[0];
}
@Override
public void run() {
try {
reproducible.execute(getInputs());
} catch (ScriptException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Only work around is keep the number instance less than 150.
SUPPORT :
YES
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b128)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b69, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux ip-172-31-38-240.us-west-2.compute.internal 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon Jun 17 15:54:20 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
EXTRA RELEVANT SYSTEM CONFIGURATION :
It is AWS "m1.xlarge" instance - with 4 core and 12 GB RAM
A DESCRIPTION OF THE PROBLEM :
Test spec:
0. JS script is compiled (once) & invoked by Invocable.invokeFunction() with various inputs multiple times.
1. 600+ line of JavaScript-code, which has ~20+ functions and encapsulated using JavaScript object constructors.
Example (which illustrates the common template on our js file):
Legacy Style Script:
function execute(someParameter){
return new complexLogic(someParameter).do();
}
function complexLogic(someParameter){
this.parameter=someParameter;
this.logic1 = function() { /*logic goes here*/}
this.logic2 = function() { /*logic goes here*/}
..
..
this.logicN = function() { /*logic goes here*/}
this.do = function(){
var finalData={};
finalData.Attribute1 = this.logic1();
finalData.Attribute2 = this.logic2();
..
..
finalData.AttributeM = this.logicN();
return finalData;
}
}
JSLint Complaint Script (where we addressed all the issues reported by JSLint):
function execute(someParameter){
return do(getComplexLogic(someParameter));
}
function getComplexLogic(someParameter){
return {
parameter=someParameter,
logic1 = function() { /*logic goes here*/}
logic2 = function() { /*logic goes here*/}
..
..
logicN = function() { /*logic goes here*/}
}
}
function do(container) {
var finalData={};
finalData.Attribute1 = container .logic1();
finalData.Attribute2 = container .logic2();
..
..
finalData.AttributeM = container .logicN();
return finalData;
}
2. Nashorn always invokes the function execute() with appropriate inputs passed on to it. Inside execute(), we construct the object and we call the low level functions encapsulated inside the object.
3. We made 300 distinct set of scripts (each script function has distinct name without any conflicts, the sorucecode is more or less same).
1st Use case (aka Shared ScriptEngine): Load all these 300 distinct set of scripts into single ScriptEngine instance & 2 parallel threads invokes the js functions one by one with corresponding ScriptEngine instance for set of inputs, repeatedly - in infinite loop until the process crashes.
2nd Use case (aka Isolated ScriptEngine): Load these 300 distinct set of scripts into its own independent ScriptEngine instance & 2 parallel threads invokes the js functions one by one with corresponding ScriptEngine instance for set of inputs, repeatedly -in infinite loop until the process crashes.
Observations:
1. Round-1:
a. Both test case failed crashed immediately, with following error.
Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
CodeCache: size=245760Kb used=243668Kb max_used=244353Kb free=2091Kb
bounds [0x00007fdb55000000, 0x00007fdb64000000, 0x00007fdb64000000]
total_blobs=45680 nmethods=45250 adapters=342
compilation: enabled
b. Workaround: To delay this problem we supplied -XX:ReservedCodeCacheSize=2g (maximum possible value for Linux JVM).
New JVM parameters are -Xms6g -XX:ReservedCodeCacheSize=2g -XX:+UseCodeCacheFlushing
2. Revised Boundary test result:
a. 1st Use case â Shared Script Engine: Stable for 200 distinct set of scripts. Failed when we test for more than 200.
b. 2nd Use case â Isolated Script Engine: Stable for 100 distinct set of scripts. Failed when we test for more than 100.
3. Failure:
a. We no longer receive âCodeCache is full. Compiler has been disabled.â Exception but it crashed with following error, we noticed that there is a enough heap-memory during this error. We also noticed that the NonHeap memory is constantly growing before it get crashed, but heap memory is under control.
Exception in thread "pool-1-thread-2"
java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z132(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$DMH/2033961110.invokeSpecial_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1408023090.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at java.lang.invoke.LambdaForm$DMH/70889489.invokeStatic_LLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/92670580.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/970100220.invokeSpecial_LLLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NFI/85938268.invoke_LLLLLL_L(LambdaForm$NFI)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/265919263.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1503490613.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1912616525.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
Exception in thread "pool-1-thread-1" java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/677211270.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/155694314.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1945608681.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/302887348.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/810806242.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at java.lang.invoke.LambdaForm$DMH/1557401603.invokeStatic_LLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/2093777852.invokeExact_MT(LambdaForm$MH)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
REGRESSION. Last worked in version 7u51
ADDITIONAL REGRESSION INFORMATION:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Same Java-code
Same JavaScript
When we compile & execute with jre.1.7.X.X it is working (though the performance is bad) fine without any issue.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should work without any exception.
ACTUAL -
In Java8 we are getting bellow exception:
Exception in thread "pool-1-thread-2"
java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z132(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$DMH/2033961110.invokeSpecial_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1408023090.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at java.lang.invoke.LambdaForm$DMH/70889489.invokeStatic_LLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/92670580.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/970100220.invokeSpecial_LLLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NFI/85938268.invoke_LLLLLL_L(LambdaForm$NFI)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/265919263.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1503490613.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1912616525.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
Exception in thread "pool-1-thread-1" java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/677211270.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/155694314.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1945608681.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/302887348.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/810806242.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at java.lang.invoke.LambdaForm$DMH/1557401603.invokeStatic_LLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/2093777852.invokeExact_MT(LambdaForm$MH)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "pool-1-thread-2"
java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z132(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$DMH/2033961110.invokeSpecial_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/1902212335.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1408023090.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.v3builder$_L258(<eval>:260)
at java.lang.invoke.LambdaForm$DMH/70889489.invokeStatic_LLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/92670580.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/970100220.invokeSpecial_LLLLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NFI/85938268.invoke_LLLLLL_L(LambdaForm$NFI)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/265919263.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/1503490613.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z132Process$_L584(<eval>:627)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1912616525.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
Exception in thread "pool-1-thread-1" java.lang.InternalError: compileToBytecode
at java.lang.invoke.MethodHandleStatics.newInternalError(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.OutOfMemoryError: Compressed class space
at sun.misc.Unsafe.defineAnonymousClass(Native Method)
at java.lang.invoke.InvokerBytecodeGenerator.loadAndInitializeInvokerClass(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.loadMethod(Unknown Source)
at java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Unknown Source)
at java.lang.invoke.LambdaForm.compileToBytecode(Unknown Source)
at java.lang.invoke.LambdaForm.checkInvocationCounter(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/677211270.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/155694314.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_$3.Z134Process$_L584(<eval>:626)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/1945608681.convert(LambdaForm$MH)
at java.lang.invoke.LambdaForm$DMH/1417570503.invokeSpecial_LLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invoke_LLL_L(Unknown Source)
at java.lang.invoke.LambdaForm$DMH/425513312.invokeStatic_LL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$NamedFunction.invokeWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm.interpretName(Unknown Source)
at java.lang.invoke.LambdaForm.interpretWithArguments(Unknown Source)
at java.lang.invoke.LambdaForm$LFI/302887348.interpret_L(LambdaForm$LFI)
at java.lang.invoke.LambdaForm$MH/810806242.linkToCallSite(LambdaForm$MH)
at jdk.nashorn.internal.scripts.Script$\^eval\_.execute_z134(<eval>:3)
at java.lang.invoke.LambdaForm$DMH/1557401603.invokeStatic_LLLL_L(LambdaForm$DMH)
at java.lang.invoke.LambdaForm$MH/2093777852.invokeExact_MT(LambdaForm$MH)
at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:502)
at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:206)
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:378)
at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:179)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeImpl(NashornScriptEngine.java:508)
at jdk.nashorn.api.scripting.NashornScriptEngine.invokeFunction(NashornScriptEngine.java:229)
at api.DefaultCaffeineEngine.getNormalizedIonString(CaffeineEngineBuilder.java:115)
at IsolatedEngineWorker.run(Startup.java:188)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.script.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Reproducible {
class Script {
private ScriptEngine engine;
public Invocable invocable;
public Script(ScriptEngine engine) {
this.engine = engine;
this.invocable = (Invocable)engine;
}
}
HashMap<Integer, Script> scripts = new HashMap<Integer, Script> ();
public void init(int numberOfInstances) throws FileNotFoundException, ScriptException {
for(int index=0; index<numberOfInstances; index++) {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
FileReader fileReader = new FileReader("/sample_" + index + ".js" );
CompiledScript script = ((Compilable)engine).compile(fileReader);
script.eval();
scripts.put(index, new Script(engine));
}
}
public void execute(Object[] inputs) throws ScriptException, NoSuchMethodException {
while(true) {
for(Object input : inputs) {
for(Script script : scripts.values()) {
script.invocable.invokeFunction("execute", input);
}
}
}
}
}
class Startup {
public static void Main() throws FileNotFoundException, ScriptException {
Reproducible reproducible = new Reproducible();
reproducible.init(200);
ExecutorService executor = Executors.newFixedThreadPool(2);
for(int i=0; i<2; i++){
Runnable worker = new Delegate(reproducible);
executor.execute(worker);
}
executor.shutdown();
while(!executor.isTerminated());
System.out.println("Bye Bye!");
}
}
class Delegate implements Runnable {
private final Reproducible reproducible;
public Delegate(Reproducible reproducible) {
this.reproducible = reproducible;
}
private Object[] getInputs() {
//The actutal implementaion to get some data from somewhere
return new Object[0];
}
@Override
public void run() {
try {
reproducible.execute(getInputs());
} catch (ScriptException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Only work around is keep the number instance less than 150.
SUPPORT :
YES