Bug 56160 - StackOverflowError when using WhileController within IfController
Summary: StackOverflowError when using WhileController within IfController
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.10
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords: PatchAvailable
: 52496 52618 53768 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-02-19 13:28 UTC by real_thuri
Modified: 2019-08-09 06:31 UTC (History)
4 users (show)



Attachments
Testplan to reproduce (4.76 KB, text/plain)
2014-02-19 13:28 UTC, real_thuri
Details
Proposed Patch (4.07 KB, patch)
2014-02-19 15:42 UTC, real_thuri
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description real_thuri 2014-02-19 13:28:23 UTC
Created attachment 31332 [details]
Testplan to reproduce

I got a Testplan that contains a WhileController below an IfController.
The condition of the IfController is false and the WhileController uses the __javaScript function to evaluate the content of a variable.

If the variable is not set (for example because it's set below the IfController before the WhileController) JMeter logs the line 

WARN  - jmeter.control.GenericController: StackOverflowError detected 

The Error doesn't bubble up but it slows down test execution.

Furthermore it's strange something below the IfController is executed/evaluated even if the condition of the if is false.
Comment 1 real_thuri 2014-02-19 15:16:52 UTC
After some debugging, the problem seems to be that the WhileController always returns the one contained sampler on nextIsNull().
Therefore nextIsAController always returns the Sampler too and never null;
(Though nextIsAController can't ever return null but at the end of the controller)

So because the WhileLoop never returns null reInitializeSubController will be called recursivly until the SOE is thrown.

But the first thing is that the WhileController.next() shouldn't have been called in the first place.

I'll try to create a patch and see what you think of it.
Comment 2 real_thuri 2014-02-19 15:42:18 UTC
Created attachment 31333 [details]
Proposed Patch

Patch for IfController so that child elements are not "touched" if the condition is false.
+ UnitTests
Comment 3 real_thuri 2014-02-19 15:48:04 UTC
The proposed patch makes the IfController return null if the condition is false on the first invocation of it's next method.

This should prevent Jmeter to dive into the children of the IfController and call their next method.
So child-controllers which always return an element and never null (e.g. WhileController with condition that is always true) won't result in a StackOverflow.

The issue may persist if the whileController is supposed to loop forever and and the if controller's condition is true.
Comment 4 Philippe Mouawad 2014-07-06 20:01:26 UTC
Although summary of 52496 may not be clear, it is the exact duplicate, see bugs already marked as duplicate

*** This bug has been marked as a duplicate of bug 52496 ***
Comment 5 Philippe Mouawad 2014-10-11 21:46:16 UTC
*** Bug 52496 has been marked as a duplicate of this bug. ***
Comment 6 Philippe Mouawad 2014-10-11 21:48:10 UTC
*** Bug 53768 has been marked as a duplicate of this bug. ***
Comment 7 Philippe Mouawad 2014-10-12 15:31:46 UTC
Date: Sun Oct 12 15:30:39 2014
New Revision: 1631189

URL: http://svn.apache.org/r1631189
Log:
Bug 56160 - StackOverflowError when using WhileController within IfController
Bugzilla Id: 56160

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java
    jmeter/trunk/src/core/org/apache/jmeter/control/IfController.java
    jmeter/trunk/src/core/org/apache/jmeter/control/TransactionController.java
    jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContext.java
    jmeter/trunk/test/src/org/apache/jmeter/control/TestIfController.java
    jmeter/trunk/xdocs/changes.xml
Comment 8 Philippe Mouawad 2014-12-06 15:43:00 UTC
*** Bug 52618 has been marked as a duplicate of this bug. ***
Comment 9 The ASF infrastructure team 2022-09-24 20:37:56 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3320