Skip to content

Process is terminating due to StackOverflowException #6813

Description

Since installing 6.1.0-preview.2 I get an StackOverflowException soon after I start PowerShell. This occurs on Mac OS X and Windows 10. This did not occur on 6.1.0-preview.1.

I suspect it has to do with my Module OnCommand-Insight as the issue did not occur when the module was not installed.

Steps to reproduce

Install 6.1.0-preview.2, then

Install-Module -Name "OnCommand-Insight" -Scope CurrentUser

Restart PowerShell

Florians-MacBook-Pro:~ florianfeldhaus$ pwsh
PowerShell v6.1.0-preview.2
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /Users/florianfeldhaus> Process is terminating due to StackOverflowException.
Abort trap: 6

Environment data

Mac OS X

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.2
OS                             Darwin 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

On Windows I was not fast enough, thus I edited the output from the 6.0.0 installation which is running fine:

PS C:\Users\Florian\Documents\GitHub> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.2
PSEdition                      Core
GitCommitId                    v6.1.0-preview.2
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. vexx32 commented on May 3, 2018

    @vexx32
    Collaborator

    You might want to leave a link to the module itself so we can actually see what's going on with it.

  2. iSazonov commented on May 3, 2018

    @iSazonov
    Collaborator

    Florian Feldhaus (@ffeldhaus) Could you please make more simple repo?

  3. ffeldhaus commented on May 3, 2018

    @ffeldhaus
    ContributorAuthor

    While I don't think it's a problem of the module, as the issue did not occur with 6.1.0-preview.1 as well as 6.0.0, 6.0.1 and 6.0.2, here's the link to the sourcecode of the OnCommand-Insight Module:
    https://github.com/ffeldhaus/OnCommand-Insight

    Module Download:
    https://github.com/ffeldhaus/OnCommand-Insight/releases/download/4.2.2/OnCommand-Insight.zip

    Module on PowerShell Gallery:
    https://www.powershellgallery.com/packages/OnCommand-Insight

    Ilya (@iSazonov) How should I make a more simple repo? As I don't know what is causing the issue, I can't really narrow it down. Do you have any ideas for debugging the PowerShell crash?

  4. vexx32 commented on May 3, 2018

    @vexx32
    Collaborator

    I would look at splitting up that massive module file into individual functions, classes, etc.

    In a file that big, you really have no good way of figuring out exactly which parts or combination of parts is really the issue. Even if you have a build script which compiles it into a singular PSM1, if at least you have the source well organised, you'll have a much easier time pinpointing what's going wrong.

  5. ffeldhaus commented on May 3, 2018

    @ffeldhaus
    ContributorAuthor

    Rain Sallow (/u/ta11ow) (@vexx32) I could split the module into multiple files. I already thought about it, but I had some trouble with building a module consisting of multiple files during my last try and thus did not spend more time on this. Regardless of that, PowerShell should not just crash. If PowerShell throws an exception, it should indicate where the Exception was thrown. As I had no trouble with PowerShell 5.1, 6.0.0, 6.0.1, 6.0.2 and 6.1.0-preview.1 I expect this to be a problem introduced with fixes or improvement for 6.1.0-preview.2.

    Any idea how to troubleshoot the issue?

  6. vexx32 commented on May 3, 2018

    @vexx32
    Collaborator

    The only thing I think you can really do in a case like this is save the module somewhere locally (not installed), hook in a debugger, and manually import the module by pointing to the PSD1 filename. If it still crashes like this, see if you can find anything useful in the debug data as it's doing the import.

  7. iSazonov commented on May 3, 2018

    @iSazonov
    Collaborator

    Any idea how to troubleshoot the issue?

    Debugger.
    You can review Release notes https://github.com/PowerShell/PowerShell/releases

  8. ffeldhaus commented on May 3, 2018

    @ffeldhaus
    ContributorAuthor

    I tried to setup debugging according to https://github.com/PowerShell/PowerShell/blob/master/docs/debugging/README.md but as I do not have a Windows Coding environment at the moment and only limited C# experience, I expect that I won't be able to setup proper PowerShell Debugging within the next days.

    That said, I consider this a ShowStopper for the release of 6.1. Not because it crashes during loading of my module, but because PowerShell should not Crash when loading a module which loads fine in previous releases.

    I checked the Changelog and found that PR #6523 did extensive changes to the Module loading code. Maybe some behavior changed causing the crashes here.

    As suggested I manually loaded the Module from file and discovered, that 6.1.0-preview.2 imports the .psm1 file without issues, but when importing the .psd1 module manifest, the Exception is thrown.

    It would be great if someone with a working Debugging environment could check the following steps which should reproduce the issue and share the findings:

    1. Download the Module from https://github.com/ffeldhaus/OnCommand-Insight/releases/download/4.2.2/OnCommand-Insight.zip
    2. Unzip OnCommand-Insight.zip
    3. Import-Module ./OnCommand-Insight.psd1

    EDIT: I noted that the Module Manifest contains german comments with non ASCII characters like ä,ö,ü, maybe some code changes do not properly handle non ASCII characters in the Module Manifest

  9. iSazonov commented on May 4, 2018

    @iSazonov
    Collaborator

    Dongbo Wang (@daxian-dbw) Could you please look the Issue

    I checked the Changelog and found that PR #6523 did extensive changes to the Module loading code. Maybe some behavior changed causing the crashes here.
    As suggested I manually loaded the Module from file and discovered, that 6.1.0-preview.2 imports the .psm1 file without issues, but when importing the .psd1 module manifest, the Exception is thrown.

  10. iSazonov commented on May 4, 2018

    @iSazonov
    Collaborator

    Related Issue #6818

  11. iSazonov commented on May 8, 2018

    @iSazonov
    Collaborator

    Florian Feldhaus (@ffeldhaus) Your manifest file seems to contain a circular reference

    RootModule = 'OnCommand-Insight'
    NestedModules = @('OnCommand-Insight')

    Please remove second line and test.

    Dup #5565

  12. daxian-dbw commented on May 8, 2018

    @daxian-dbw
    Member

    Florian Feldhaus (@ffeldhaus) Thanks for reporting the bug. This is a regression introduced from #6523, in PSModuleInfo.cs. A circular nested module check was removed because the comment there suggested it happens only with a deprecated workflow module. This causes a StackOverflow exception when running into circular nested modules.

    As Ilya (@iSazonov) pointed out, your module manifest is not well structured. The RootModule shouldn't be put in the NestedModules again, though that shouldn't make powershell crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions