Skip to content
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

PowerShell 7 APPCRASH System.ArgumentOutOfRangeException #20860

Closed
5 tasks done
DarkLite1 opened this issue Dec 7, 2023 · 5 comments
Closed
5 tasks done

PowerShell 7 APPCRASH System.ArgumentOutOfRangeException #20860

DarkLite1 opened this issue Dec 7, 2023 · 5 comments
Labels
Resolution-Duplicate The issue is a duplicate.

Comments

@DarkLite1
Copy link

DarkLite1 commented Dec 7, 2023

Prerequisites

Steps to reproduce

We are experiencing a problem that PowerShell 7.4.0 crashes when using Set-SFTPItem in parallel running jobs. We also reported this in issue 556 of the Open-SSH module.

Looking in the Windows Event Viewer we see 3 errors which happen at exactly the same time. This makes us believe it's the PowerShell process that crashes within the PowerShell background job started by Start-Job.

Possibly related to .NET version 8, see this issue with a similar error message.

See attachment for the event logs.
Event log errors.zip
pwsh.exe.23908.zip

Repro

Install-Module Posh-ssh
# Main script "Get or send SFTP file.ps1"
$actions | foreach-Object {
   $invokeParams = @{
           FilePath     = '../Send to SFTP.ps1'
           ArgumentList = ....
   }
   Start-Job @invokeParams
}
# Child script "Send to SFTP.ps1"
$ErrorActionPreference = 'Stop'

$params = @{
    ComputerName = $SftpComputerName
    Credential   = $sftpCredential
    AcceptKey    = $true
}
$sftpSession = New-SFTPSession @params

$sessionParams = @{
    SessionId = $sftpSession.SessionID
}
try {
   $params = @{
        Path        = $tempFile.UploadFilePath
        Destination = $SftpPath
   }
   Write-Verbose 'Upload file'
   Set-SFTPItem @sessionParams @params
   Write-Verbose 'File uploaded'
}
catch {
   throw "Failed to upload file: $_"
}

Expected behavior

One of two things:
- See the verbose message "File uploaded"
- See the error message "Failed to upload file: reason"

Actual behavior

When enabling `Start-Transcript` we can see:
> VERBOSE: Upload file

Nothing else after this line. It didn't go to the `catch` clause and no upload has happened. The PowerShell job just crashed.

Error details

The background process reported an error with the following message: Unhandled exception. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index').

Environment data

PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@DarkLite1 DarkLite1 added the Needs-Triage The issue is new and needs to be triaged by a work group. label Dec 7, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage The issue is new and needs to be triaged by a work group. label Dec 7, 2023
Copy link
Contributor

microsoft-github-policy-service bot commented Dec 7, 2023

📣 Hey @DarkLite1, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://forms.office.com/r/P926k48jRJ

@jkotas
Copy link
Contributor

jkotas commented Dec 8, 2023

Likely duplicate of #16894

@iSazonov iSazonov added the Resolution-Duplicate The issue is a duplicate. label Dec 8, 2023
Copy link
Contributor

This issue has been marked as duplicate and has not had any activity for 1 day. It has been closed for housekeeping purposes.

Copy link
Contributor

📣 Hey @DarkLite1, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 aka.ms/PSRepoFeedback

@DarkLite1
Copy link
Author

Indeed, it does seem to be related. Thank you for pointing us in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Duplicate The issue is a duplicate.
Projects
None yet
Development

No branches or pull requests

3 participants