lesscss-engine icon indicating copy to clipboard operation
lesscss-engine copied to clipboard

LESS compilation results in busy loop, thread hangs, with Nashorn engine

Open bradmac opened this issue 10 years ago • 0 comments

Compiling bootstrap occasionally results in a thread hung indefinitely in a busy loop. Usually it compiles in a few seconds, but i've been seeing it stuck for several hours at times.

Assuming that the problem is buried deep within either the LESS or Nashorn code a fix might be out of reach. I could detect the stuck thread and interrupt it with application code, but apparently nashorn doesnt check interrupt status. However, this can be done from within the JS. Would it be possible to insert something like this into some suitable processing loop?

if (java.lang.Thread.interrupted()) break;

See commentary about interrupting Nashorn scripts here - http://stackoverflow.com/questions/24855182/interrupt-java-thread-running-nashorn-script

Thread stack is probably not much help, its mostly lamdas:

java.lang.Thread.State: RUNNABLE at jdk.nashorn.internal.runtime.ScriptRuntime.EQ_STRICT(ScriptRuntime.java:767) at jdk.nashorn.internal.runtime.ScriptRuntime.NE_STRICT(ScriptRuntime.java:779) at java.lang.invoke.LambdaForm$DMH/1653016297.invokeStatic_LL_I(LambdaForm$DMH) at java.lang.invoke.LambdaForm$MH/1620750378.convert(LambdaForm$MH) at java.lang.invoke.LambdaForm$MH/1064733140.linkToCallSite(LambdaForm$MH) at jdk.nashorn.internal.scripts.Script$^eval_$2._L15$Parser$getLocation(:310) ... many more... at java.lang.invoke.LambdaForm$MH/522631210.linkToCallSite(LambdaForm$MH) at jdk.nashorn.internal.scripts.Script$^eval_._L12(:64) at java.lang.invoke.LambdaForm$DMH/883214287.invokeStatic_LLLLL_L(LambdaForm$DMH) at java.lang.invoke.LambdaForm$MH/664550332.invokeExact_MT(LambdaForm$MH) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:504) 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.call(ScriptObjectMirror.java:107) at com.asual.lesscss.compiler.NashornCompiler.compile(NashornCompiler.java:77) at com.asual.lesscss.LessEngine.compile(LessEngine.java:107) at com.asual.lesscss.LessEngine.compile(LessEngine.java:101)

bradmac avatar Oct 15 '14 09:10 bradmac