Stack overflow exception in Concurrency Thread group.

329 views
Skip to first unread message

K

unread,
Nov 25, 2023, 2:51:02 PM11/25/23
to jmeter-plugins
I am using concurrency thread group and I am observing a strange behaviour while running my tests. When I run it with just one user, and having one while controller which runs on condition while hasNextPage is true, The test runs fine for first sample, the first thread closes gracefully, But when next thread starts I get the following exception:

JMeter: Uncaught exception in thread Thread[xxx filter-ThreadStarter 2-1,6,main]
java.lang.StackOverflowError: null
    at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:1031) ~[?:1.8.0_382]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:400) ~[?:1.8.0_382]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:405) ~[?:1.8.0_382]
    at jdk.nashorn.internal.runtime.ScriptLoader.loadClass(ScriptLoader.java:55) ~[nashorn.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_382]
    at java.lang.Class.getDeclaredFields0(Native Method) ~[?:1.8.0_382]
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583) ~[?:1.8.0_382]
    at java.lang.Class.getDeclaredField(Class.java:2068) ~[?:1.8.0_382]
    at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller$1.run(Context.java:209) ~[nashorn.jar:?]
    at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller$1.run(Context.java:204) ~[nashorn.jar:?]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_382]
    at jdk.nashorn.internal.runtime.Context$ContextCodeInstaller.initialize(Context.java:204) ~[nashorn.jar:?]
    at jdk.nashorn.internal.codegen.CompilationPhase$InstallPhase.transform(CompilationPhase.java:508) ~[nashorn.jar:?]
    at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:624) ~[nashorn.jar:?]
    at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:655) ~[nashorn.jar:?]
    at jdk.nashorn.internal.runtime.Context.compile(Context.java:1317) ~[nashorn.jar:?]
    at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1251) ~[nashorn.jar:?]
    at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:627) ~[nashorn.jar:?]
    at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:535) ~[nashorn.jar:?]
    at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:524) ~[nashorn.jar:?]
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402) ~[nashorn.jar:?]
    at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155) ~[nashorn.jar:?]
    at org.apache.jmeter.functions.JavaScript.executeWithNashorn(JavaScript.java:141) ~[ApacheJMeter_functions.jar:5.5]
    at org.apache.jmeter.functions.JavaScript.execute(JavaScript.java:102) ~[ApacheJMeter_functions.jar:5.5]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:138) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:113) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:100) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.WhileController.getCondition(WhileController.java:142) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.WhileController.endOfLoop(WhileController.java:62) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.WhileController.next(WhileController.java:112) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.InterleaveControl.nextIsAController(InterleaveControl.java:104) ~[ApacheJMeter_components.jar:5.5]
    at org.apache.jmeter.control.GenericController.next(GenericController.java:175) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.InterleaveControl.next(InterleaveControl.java:96) ~[ApacheJMeter_components.jar:5.5]
    at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:222) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.GenericController.next(GenericController.java:175) ~[ApacheJMeter_core.jar:5.5]
    at com.blazemeter.jmeter.control.VirtualUserController.next(VirtualUserController.java:41) ~[jmeter-plugins-casutg-2.10.jar:?]
    at com.blazemeter.jmeter.control.VirtualUserController.nextIsNull(VirtualUserController.java:86) ~[jmeter-plugins-casutg-2.10.jar:?]
    at org.apache.jmeter.control.GenericController.next(GenericController.java:170) ~[ApacheJMeter_core.jar:5.5]
    at com.blazemeter.jmeter.control.VirtualUserController.next(VirtualUserController.java:41) ~[jmeter-plugins-casutg-2.10.jar:?]
    at org.apache.jmeter.control.GenericController.nextIsAController(GenericController.java:225) ~[ApacheJMeter_core.jar:5.5]
    at org.apache.jmeter.control.GenericController.next(GenericController.java:175) ~[ApacheJMeter_core.jar:5.5]
    at com.blazemeter.jmeter.control.VirtualUserController.next(VirtualUserController.java:41) ~[jmeter-plugins-casutg-2.10.jar:?]
    at com.blazemeter.jmeter.control.VirtualUserController.nextIsNull(VirtualUserController.java:86) ~[jmeter-plugins-casutg-2.10.jar:?]
    at org.apache.jmeter.control.GenericController.next(GenericController.java:170) ~[ApacheJMeter_core.jar:5.5]
    at com.blazemeter.jmeter.control.VirtualUserController.next(VirtualUserController.java:41) ~[jmeter-plugins-casutg-2.10.jar:?]


I tried with simple thread group and It is not giving any exception, what may be the possible cause and how can I mitigate this?

Dmitri T

unread,
Nov 26, 2023, 8:20:14 AM11/26/23
to jmeter-plugins
You're using __javaScript() function somewhere in the Concurrency Thread Group and the code you've written there produces some form of an endless loop so you need to revisit and fix this code.

Also going forward I would suggest re-considering the approach as:
  1. Using __javaScript() is some form of a performance anti-pattern, you should rather go for __jexl3() or __groovy()
  2. Nashorn engine has been removed from OpenJDK 15+  so in future you won't be able to use __javaScript() function and language in JSR223 test element.

K

unread,
Nov 27, 2023, 6:17:42 AM11/27/23
to jmeter-plugins
Hi @Dmitri T,
Thanks for responding , I have reviewed my loop condition and it turns out that my loop is working fine and it is even breaking out at the condition, but the stackoverflow happens when the new thread starts and then only the error is throws, what may be the possible causes?


2023-11-27 16:27:22,595 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[apps all results filter-ThreadStarter 2-1,6,main]
java.lang.StackOverflowError: null

at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_382]
at java.io.BufferedWriter.<init>(BufferedWriter.java:109) ~[?:1.8.0_382]
at java.io.BufferedWriter.<init>(BufferedWriter.java:88) ~[?:1.8.0_382]
at java.io.PrintWriter.<init>(PrintWriter.java:148) ~[?:1.8.0_382]
at javax.script.SimpleScriptContext.<init>(SimpleScriptContext.java:92) ~[?:1.8.0_382]
at javax.script.AbstractScriptEngine.getScriptContext(AbstractScriptEngine.java:290) ~[?:1.8.0_382]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:231) ~[?:1.8.0_382]
at org.apache.jmeter.functions.Groovy.execute(Groovy.java:120) ~[ApacheJMeter_functions.jar:5.5]

K

unread,
Nov 27, 2023, 6:46:32 AM11/27/23
to jmeter-plugins
Here is something worth noticing:

2023-11-27 17:12:50,353 INFO o.a.j.t.JMeterThread: Thread finished: apps all results filter-ThreadStarter 2-1
2023-11-27 17:12:50,354 INFO o.a.j.t.JMeterThread: Thread started: apps all results filter-ThreadStarter 2-2
2023-11-27 17:12:50,355 INFO o.a.j.u.BeanShellTestElement: PREH: true
2023-11-27 17:12:50,355 INFO o.a.j.u.BeanShellTestElement: LC: null
2023-11-27 17:12:50,355 INFO o.a.j.u.BeanShellTestElement: PREFirst: 10
2023-11-27 17:12:50,355 INFO o.a.j.u.BeanShellTestElement: FirstProd: "xxx"
2023-11-27 17:12:50,355 INFO o.a.j.u.BeanShellTestElement: Flag: 0
2023-11-27 17:12:50,353 ERROR o.a.j.JMeter: Uncaught exception in thread Thread[apps all results filter-ThreadStarter 2-1,6,main]
java.lang.StackOverflowError: null


It says that the ThreadStarter 2-1 has finished and It is starting the ThreadStarter 2-2 , But how when the thread 2-1 has ended it is throwing exception for ThreadStarter 2-1,6,main
Reply all
Reply to author
Forward
0 new messages