-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
This is not happening on PS 5.1
Issue was first identified when expanding multiple 7z archives with Start-ThreadJob and Expand-7Zip cmdlet from 7Zip4PowerShell module. It might be also related to this issue with corresponding PR
Issue description:
When using a cmdlet that opens multiple progress panes on PS 7.4.0, a NullReferenceException is thrown occasionally on progress pan completion. Please refer to above links for more details.
Workaround:
Disable progress before calling cmdlet that opens multiple progress panes with $ProgressPreference = 'SilentlyContinue'
Expected behavior
NullReferenceException on ProgressPane completion should not happenActual behavior
Occasionally an exception is thrown that "Object reference not set to an instance of an object" at Microsoft.PowerShell.ProgressPane.Hide()Error details
TargetSite : Void Hide()
Message : Object reference not set to an instance of an object.
Data : {}
InnerException :
HelpLink :
Source : Microsoft.PowerShell.ConsoleHost
Result : -2147467261
StackTrace : at Microsoft.PowerShell.ProgressPane.Hide()
at Microsoft.PowerShell.ProgressPane.Show(PendingProgress pendingProgress)
at Microsoft.PowerShell.ConsoleHostUserInterface.HandleIncomingProgressRecord(Int64 sourceId, ProgressRecord record)
at Microsoft.PowerShell.ConsoleHostUserInterface.WriteProgress(Int64 sourceId, ProgressRecord record)
at System.Management.Automation.Internal.Host.InternalHostUserInterface.WriteProgress(Int64 sourceId, ProgressRecord record)
at System.Management.Automation.MshCommandRuntime.WriteProgress(Int64 sourceId, ProgressRecord progressRecord, Boolean overrideInquire)
at System.Management.Automation.Cmdlet.WriteProgress(ProgressRecord progressRecord) at SevenZip4PowerShell.ThreadedCmdlet.EndProcessing() in C:\Users\---\Documents\Visual Studio 2022\Projects\72ip4PowerShe11\72ip4Powershell\ThreadedCmdlet.cs:line 29Environment data
Name Value
---- -----
PSVersion 7.4.0
PSEdition Core
GitCommitId 7.4.0
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Edit: 2025-01-31
Script to reproduce the NRE's:
- Save as
Test-ProgressBar.ps1 - Dot-source
- Execute
Test-ProgressBar -Verboseto trigger NREs - Execute
Test-ProgressBarno errors
#Requires -Version 7.5 -Modules Microsoft.PowerShell.ThreadJob
function Test-ProgressBar {
[CmdletBinding()]
param()
$Global:ProgressPreference = 'Continue'
$PSStyle.Progress.MaxWidth = $Host.UI.RawUI.WindowSize.Width
$splatThreadJob = @{
ThrottleLimit = [Environment]::ProcessorCount
StreamingHost = $Host
}
$isVerbose = $PSBoundParameters['Verbose'] -eq $true
$threadJobs = 1..50 | ForEach-Object {
Start-ThreadJob -Name $_ -ScriptBlock {
try {
$VerbosePreference = if ($Using:isVerbose) {'Continue'} else {'SilentlyContinue'}
$progressBarId = $Using:_
$progressBar = 'ProgressBar-{0}' -f $progressBarId
foreach ($n in 0..100) {
Write-Progress -Activity $progressBar -Status ('{0}%' -f $n) -PercentComplete $n -Id $progressBarId
Start-Sleep -Milliseconds (Get-Random -Minimum 15 -Maximum 45)
}
Write-Progress -Activity $progressBar -Completed -Id $progressBarId
Write-Verbose -Message (
'Progress bar completted: "{0}"' -f
$progressBar
)
} catch {
# Write-Warning ('[PID: "{0}" | RID: "{1}"]' -f
# $PID,
# [Management.Automation.Runspaces.Runspace]::DefaultRunspace.Id,
# $_.Exception.Message
# )
# Wait-Debugger
throw $_
}
} @splatThreadJob
}
$null = Wait-Job -Job $threadJobs | Receive-Job
Remove-Job -Job $threadJobs -Force
}Visuals:
iSazonov
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation

