Skip to content

InsufficientExecutionStackException: Insufficient stack to continue executing the program safely. #3963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 6 tasks
raandree opened this issue May 9, 2022 · 6 comments
Labels
Bug: PowerShell 5.1 Bugs when using PowerShell 5.1. Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@raandree
Copy link

raandree commented May 9, 2022

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Since upgrading the PowerShell extension to 2022.5.1, some Pester tests in a few projects are failing with this error and if there are more than 5 test cases:

[-] DSCFile01 has a valid Configurations Setting (!$null) 60ms (56ms|4ms)
    ScriptCallDepthException: The script failed due to call depth overflow.
    RuntimeException: The script failed due to call depth overflow.

I don't see any recursive calls in the Pester code.

This only fails in the PowerShell Integrated Console and works fine in the console just named 'powershell`.

I have tried to narrow it down a bit. If I lower the number if test cases to 5 in .\tests\ConfigData\CompositeResources.Tests.ps1::67 ($testCases[0..4), the tests pass. If I add one ($testCases[0..5]), I get a ScriptCallDepthException.

If I downgrade to the PowerShell extension version 2021.12.0, things run regardless how many test cases I have.

@nohwnd, have you seen something similar by any chance?

PowerShell Version

Name                           Value                                                                                                                                                                   
----                           -----                                                                                                                                                                   
PSVersion                      5.1.22000.613                                                                                                                                                           
PSEdition                      Desktop                                                                                                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                 
BuildVersion                   10.0.22000.613                                                                                                                                                          
CLRVersion                     4.0.30319.42000                                                                                                                                                         
WSManStackVersion              3.0                                                                                                                                                                     
PSRemotingProtocolVersion      2.3                                                                                                                                                                     
SerializationVersion           1.1.0.1

Visual Studio Code Version

1.67.0
57fd6d0195bb9b9d1b49f6da5db789060795de47
x64

Extension Version

Steps to Reproduce

In a VSCode terminal:

git clone https://github.com/dsccommunity/DscWorkshop.git d:\DscWorkshop
cd D:\DscWorkshop\
git checkout test/InsufficientExecutionStackException
.\build.ps1 -ResolveDependency

Visuals

NA

Logs

PS D:\Git\DscWorkshop> .\build.ps1
[pre-build] Starting Build Init
[pre-build] Pre-pending 'D:\Git\DscWorkshop\output\RequiredModules' folder to PSModulePath
[build] Starting build with InvokeBuild.
[build] Parsing defined tasks
[build] Loading Configuration from D:\Git\DscWorkshop\build.yaml
[build] Pre-pending 'D:\Git\DscWorkshop\output\AvoidPSPathOverlap' folder to PSModulePath
Importing tasks from module Sampler
         Loading Build-Module.ModuleBuilder.build.Sampler.ib.tasks...
         Loading ChocolateyPackage.build.Sampler.ib.tasks...
         Loading Clean.ModuleBuilder.build.Sampler.ib.tasks...
         Loading DeployAll.PSDeploy.build.Sampler.ib.tasks...
         Loading DscResource.Test.build.Sampler.ib.tasks...
         Loading generateHelp.PlatyPS.build.Sampler.ib.tasks...
         Loading GuestConfig.build.Sampler.ib.tasks...
         Loading Invoke-Pester.pester.build.Sampler.ib.tasks...
         Loading JaCoCo.coverage.build.Sampler.ib.tasks...
         Loading release.module.build.Sampler.ib.tasks...
         Loading Set-BuildEnvironment.BuildHelpers.build.Sampler.ib.tasks...
         Loading Set-SamplerTaskVariable...
Importing tasks from module Sampler.DscPipeline
         Loading CompileDatumRsop.build.Sampler.DscPipeline.ib.tasks...
         Loading CompileRootConfiguration.build.Sampler.DscPipeline.ib.tasks...
         Loading CompileRootMetaMof.build.Sampler.DscPipeline.ib.tasks...
         Loading CompressArtifactCollections.build.Sampler.DscPipeline.ib.tasks...
         Loading CompressModulesWithChecksum.build.Sampler.DscPipeline.ib.tasks...
         Loading LoadDatumConfigData.build.Sampler.DscPipeline.ib.tasks...
         Loading NewMofChecksums.build.Sampler.DscPipeline.ib.tasks...
         Loading TestBuildAcceptance.build.Sampler.DscPipeline.ib.tasks...
         Loading TestConfigData.build.Sampler.DscPipeline.ib.tasks...
         Loading TestDscResources.build.Sampler.DscPipeline.ib.tasks...
Adding Workflow from configuration:
  +-> pack
  +-> init
  +-> build
  +-> .
[build] Executing requested workflow: .
Build . D:\Git\DscWorkshop\build.ps1
Redefined task '.'.

===============================================================================
                        INIT

-------------------------------------------------------------------------------
  /./build/Init
  D:\Git\DscWorkshop\build.ps1:331

Done /./build/Init 00:00:00.0389991

===============================================================================
                        CLEAN
Deleting the content of the Build Output folder, except ./modules
-------------------------------------------------------------------------------
  /./build/Clean
  D:\Git\DscWorkshop\output\RequiredModules\Sampler\0.112.3\tasks\Clean.ModuleBuilder.build.ps1:16

Removing D:\Git\DscWorkshop\output\* excluding RequiredModules
Done /./build/Clean 00:00:00.0244961

===============================================================================
                        LOADDATUMCONFIGDATA

-------------------------------------------------------------------------------
  /./build/LoadDatumConfigData
  D:\Git\DscWorkshop\output\RequiredModules\Sampler.DscPipeline\0.2.0\tasks\LoadDatumConfigData.build.ps1:30

Loading Datum Definition from 'D:\Git\DscWorkshop\source\Datum.yml'
Done /./build/LoadDatumConfigData 00:00:00.6779985

===============================================================================
                        TESTCONFIGDATA

-------------------------------------------------------------------------------
  /./build/TestConfigData
  D:\Git\DscWorkshop\output\RequiredModules\Sampler.DscPipeline\0.2.0\tasks\TestConfigData.build.ps1:43

        Project Name               = 'DscWorkshop'
        Source Path                = 'source'
        Output Directory           = 'D:\Git\DscWorkshop\output'
        Release Notes path         = 'D:\Git\DscWorkshop\output\ReleaseNotes.md'
        Built Module Subdirectory  = 'D:\Git\DscWorkshop\output\AvoidPSPathOverlap'
        Module Manifest Path (src) = 'D:\Git\DscWorkshop\source\DscWorkshop.psd1'
        Module Version             = '0.2.0-test'

        Pester Output Folder    = 'D:\Git\DscWorkshop\output\testResults
Creating folder D:\Git\DscWorkshop\output\testResults
Config Data Pester Scripts = [D:\Git\DscWorkshop\tests\ConfigData]
TestResultsPath is: D:\Git\DscWorkshop\output\testResults\IntegrationTestResults.xml
OutputDirectory is: D:\Git\DscWorkshop\output\testResults
Pester v5.3.3

Starting discovery in 2 files.
Discovery found 38 tests in 375ms.
Filter 'Tag' set to ('Integration').
Filters selected 38 tests to run.
Running tests.

Running tests from 'CompositeResources.Tests.ps1'
Describing Resources matching between Composite Resources and PSDepend file
 Context Composite Resources import correct DSC Resources
   [+] DSC Resource Module 'ComputerManagementDsc' is defined in 'RequiredModules.psd1' 124ms (84ms|40ms)
   [+] DSC Resource Module 'xPSDesiredStateConfiguration' is defined in 'RequiredModules.psd1' 4ms (2ms|1ms)
   [+] DSC Resource Module 'JeaDsc' is defined in 'RequiredModules.psd1' 3ms (2ms|1ms)
   [+] DSC Resource Module 'xPSDesiredStateConfiguration' is defined in 'RequiredModules.psd1' 4ms (2ms|1ms)
   [+] DSC Resource Module 'ComputerManagementDsc' is defined in 'RequiredModules.psd1' 4ms (2ms|1ms)
   [+] DSC Resource Module 'xPSDesiredStateConfiguration' is defined in 'RequiredModules.psd1' 4ms (2ms|2ms)
   [+] Version of 'ComputerManagementDsc' in 'ComputerSettings.schema.psm1' is equal to version in 'RequiredModules.psd1' 5ms (3ms|1ms)
   [+] Version of 'xPSDesiredStateConfiguration' in 'ConfigurationBase.schema.psm1' is equal to version in 'RequiredModules.psd1' 2ms (1ms|1ms)
   [+] Version of 'JeaDsc' in 'DscDiagnostic.schema.psm1' is equal to version in 'RequiredModules.psd1' 2ms (1ms|1ms)
   [+] Version of 'xPSDesiredStateConfiguration' in 'DscLcmController.schema.psm1' is equal to version in 'RequiredModules.psd1' 2ms (1ms|1ms)
   [+] Version of 'ComputerManagementDsc' in 'DscLcmController.schema.psm1' is equal to version in 'RequiredModules.psd1' 2ms (1ms|1ms)
   [+] Version of 'xPSDesiredStateConfiguration' in 'DscLcmMaintenanceWindows.schema.psm1' is equal to version in 'RequiredModules.psd1' 3ms (1ms|2ms)

Running tests from 'ConfigData.Tests.ps1'
Describing Validate All Definition Files
  [+] 'DSCFile01.yml' is a valid yaml 56ms (53ms|2ms)
  [+] 'DscLcm.yml' is a valid yaml 28ms (27ms|1ms)
  [+] 'Security.yml' is a valid yaml 10ms (9ms|1ms)
  [+] 'Server.yml' is a valid yaml 22ms (21ms|1ms)
  [+] 'Dev.yml' is a valid yaml 12ms (11ms|1ms)
  [+] 'Prod.yml' is a valid yaml 8ms (7ms|2ms)
  [+] 'Test.yml' is a valid yaml 73ms (71ms|1ms)
  [+] 'Domain.yml' is a valid yaml 7ms (6ms|1ms)
  [+] 'Frankfurt.yml' is a valid yaml 14ms (12ms|1ms)
  [+] 'London.yml' is a valid yaml 9ms (8ms|1ms)
  [+] 'Singapore.yml' is a valid yaml 9ms (8ms|1ms)
  [+] 'Tokio.yml' is a valid yaml 9ms (7ms|1ms)
  [+] 'DomainController.yml' is a valid yaml 11ms (10ms|2ms)
  [+] 'FileServer.yml' is a valid yaml 27ms (26ms|1ms)
  [+] 'WebServer.yml' is a valid yaml 49ms (48ms|1ms)
  [+] 'Datum.yml' is a valid yaml 32ms (31ms|1ms)

Describing Datum Tree Definition
  [+] Exists in source Folder 37ms (29ms|7ms)
  [+] Is Valid Yaml 40ms (39ms|1ms)
  [+] 'Get-FilteredConfigurationData' returned data 12ms (11ms|1ms)

Describing Node Definition Files
 Context Testing for conflicts / duplicate data
   [+] Should not have duplicate node names 8ms (3ms|5ms)
  [+] 'DSCFile01' has valid yaml 40ms (33ms|6ms)
  [+] 'DSCFile01' is in the right environment 13ms (4ms|9ms)
  [+] Location of 'DSCFile01' is 'Frankfurt' and does exist 16ms (14ms|1ms)
 Describing Roles Definition Files
   [+] D:\Git\DscWorkshop\source\Roles\FileServer.yml has valid yaml 62ms (56ms|6ms)
 Describing Role Composition
   [-] DSCFile01 has a valid Configurations Setting (!$null) 86ms (82ms|4ms)
[-] Describe Node Definition Files.Role Composition failed
   ScriptCallDepthException: The script failed due to call depth overflow.
   RuntimeException: The script failed due to call depth overflow.
Tests completed in 1.89s
Tests Passed: 36, Failed: 2, Skipped: 0 NotRun: 0
BeforeAll \ AfterAll failed: 1
  - Node Definition Files.Role Composition
ERROR: Assertion failed.
At D:\Git\DscWorkshop\output\RequiredModules\Sampler.DscPipeline\0.2.0\tasks\TestConfigData.build.ps1:98 char:5
+     assert ($testResults.FailedCount -eq 0 -and $testResults.FailedBl ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At D:\Git\DscWorkshop\output\RequiredModules\Sampler.DscPipeline\0.2.0\tasks\TestConfigData.build.ps1:43 char:1
+ task TestConfigData -if ($CurrentJobNumber -eq 1) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 6 tasks, 1 errors, 0 warnings 00:00:06.7105615
assert : Assertion failed.
At D:\Git\DscWorkshop\output\RequiredModules\Sampler.DscPipeline\0.2.0\tasks\TestConfigData.build.ps1:98 char:5
+     assert ($testResults.FailedCount -eq 0 -and $testResults.FailedBl ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Assert-Build], Exception
    + FullyQualifiedErrorId : Assert-Build
@raandree raandree added the Issue-Bug A bug to squash. label May 9, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label May 9, 2022
@nohwnd
Copy link
Contributor

nohwnd commented May 10, 2022

There are few issues reported on this, it seems that the stack capacity is really small in that version of PS when running in a job:

What these issue don't mention (AFAIK) is failing when there are more testcases. It also does not sound plausible to me, because test cases are flat, and there is no difference (scope depth wise) from having 1 test with no test cases, and a test with 1 or 10 test cases.

Invoke-Pester -Container (New-PesterContainer -ScriptBlock {
    BeforeAll {
        function How-Deep () { 
            $s = 1
            while (-not (Get-Variable -Scope $s -Name Error -ErrorAction Ignore)) {
                $s++
            }
            $s - 1
        }
    }

    Describe "a" { 
        It "b" { 
            Write-Host (How-Deep)
        }

        It "c" -TestCases @{ a = "b" } {
            Write-Host (How-Deep)
        }

        It "d" -TestCases @(
            @{ a = "b" }
            @{ a = "b" }
            @{ a = "b" }
        ) {
            Write-Host (How-Deep)
        }
    }
}) -Output Detailed
Pester v5.3.3

Starting discovery in 1 files.
Discovery found 5 tests in 18ms.
Running tests.
Describing a
6
  [+] b 5ms (3ms|1ms)
6
  [+] c 4ms (3ms|1ms)
6
  [+] d 5ms (3ms|1ms)
6
  [+] d 2ms (1ms|1ms)
6
  [+] d 2ms (1ms|1ms)
Tests completed in 69ms
Tests Passed: 5, Failed: 0, Skipped: 0 NotRun: 0

You can try seeing how much of callstack is left for you:

pester/Pester#822 (comment)

Or maybe some of the other issues has more hints: https://github.com/search?q=org%3Apester+The+script+failed+due+to+call+depth+overflow+is%3Aissue&type=issues

We classified it as external bug.

@andyleejordan
Copy link
Member

@fflaten summarized what's going on well here: #3962 (comment)

@andyleejordan andyleejordan added Resolution-External Will close automatically. Bug: PowerShell 5.1 Bugs when using PowerShell 5.1. Needs: Triage Maintainer attention needed! and removed Needs: Triage Maintainer attention needed! Resolution-External Will close automatically. labels May 10, 2022
@andyleejordan
Copy link
Member

Mm, it is really weird it's happening only in the IC (though plausible as other overhead is incurred since it's servicing LSP requests etc.) and only with more tests being run...

@JasonLord711
Copy link

I appear to have the same issue. I only noticed it yesterday - it had been working as recently as 3 weeks ago. I use VSCode (Windows). I get when I run the command below more than once in the same VSCode session. OR if it finds more than 1 or 2 .Test.ps1 files then it will return the error after 1 or 2 .Test files. All Test files pass when run individually. The only "change" I know of is VSCode just released an update (however I tried backing out the update and it still failed)

$TestAllPath="C:\Users\s1899925\GitHub\ReconNET-Tools_Testing"
$ErrorActionPreference='silentlycontinue'

Invoke-Pester -Output Detailed -Path $TestAllPath

@andyleejordan
Copy link
Member

This just got fixed by @nohwnd in PowerShell/PowerShellEditorServices#1797. We'll get a release out ASAP.

@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Triage Maintainer attention needed! labels May 11, 2022
@ghost ghost closed this as completed May 11, 2022
@ghost
Copy link

ghost commented May 11, 2022

This issue has been marked as fixed. It has been automatically closed for housekeeping purposes.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: PowerShell 5.1 Bugs when using PowerShell 5.1. Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
No open projects
Status: Done
Development

No branches or pull requests

4 participants