function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andrea RaspitzuAndrea Raspitzu 

Maximum stack depth reached: 11

Hi all,

i recently started encountering the mighty "System.LimitException: Maximum stack depth reached: 11" during some apex development in a sandbox. The apex code we are developing is a BPM (Business process management) tool, so far it has been good but after the last changes it has to handle a quite some data; assuming we don't have an infinite recursion in our code could the error be due to the large amount of data (and thus large number of statements) being involved? If yes why do i see the number 11 in the error?
Andrea RaspitzuAndrea Raspitzu
Stack trace + part of the log

16:17:02.647 (1647450328)|STATEMENT_EXECUTE|[55]
16:17:02.647 (1647453052)|STATEMENT_EXECUTE|[56]
16:17:02.647 (1647504336)|VARIABLE_ASSIGNMENT|[56]|this.CapTarDayTariffTaxed__c|0.62363400|0x1f2cebd
16:17:02.647 (1647511072)|STATEMENT_EXECUTE|[57]
16:17:02.647 (1647551972)|VARIABLE_ASSIGNMENT|[57]|this.GosTariffTaxed__c|null|0x1f2cebd
16:17:02.647 (1647576000)|SYSTEM_METHOD_ENTRY|[58]|String.equals(Object)
16:17:02.647 (1647589094)|SYSTEM_METHOD_EXIT|[58]|String.equals(Object)
16:17:02.647 (1647594543)|STATEMENT_EXECUTE|[59]
16:17:02.649 (1649543754)|HEAP_ALLOCATE|[59]|Bytes:35
16:17:02.649 (1649607113)|SYSTEM_MODE_EXIT|false
16:17:02.649 (1649695610)|FATAL_ERROR|System.LimitException: Maximum stack depth reached: 11

Class.EcedoConverter.convertEcedoOrganizationAndEcedoConnectionsToFullState: line 59, column 1
Class.EcedoSyncService.getEcedoStateForOrganization: line 26, column 1
Class.FlowStep_RefreshDataFromEcedo.execute: line 25, column 1
Class.FlowStepExecutor.executeImpl: line 31, column 1
Class.FlowStepExecutor.execute: line 11, column 1
Class.FlowRunner.runStep: line 121, column 1
Class.FlowRunner.runSteps: line 73, column 1
Class.FlowRunner.runFlowWithState: line 62, column 1
Class.FlowRunner.runFlow: line 39, column 1
Class.Controller_FlowRunPage.runFlow: line 46, column 1
Class.Controller_FlowRunPage.runFromPage: line 30, column 1

 
docbilldocbill
When I see this error it is always related to having debugging enabled.   Amoung other issues, I suspect there is a bug in the way profiling works with virtual methods.  At some point salesforce loses track of the stack depth in this instance and will throw an error at a completely inappropriate section of the code.   Two years agon this happened all the time, then salseforce did something that fixed it for us.   Today it started again.   When I checked the debug levels, I noticed "Profiling : Debug" is no longer an option.   My guess is there are certain combinations of debug options that cause this problem, so salesforce removed those as picklist options.   However, if you have an old Debug Level defined, it can still reference one of these illegal combinations.