Race condition exception when accessing $Host.UI.psobject.Properties inside a runspace
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- powershell
- 領域
- backend
研究方向
Start with the $Host.UI.psobject.Properties access in the supplied reproduction and the related Pester reproduction, then inspect the ThreadJob runspace and -StreamingHost handling. Run the reproduction on the stated PowerShell and Windows versions, repeating it in fresh sessions because the failure is sporadic. Done means neither reproduction produces the null-array exception.
由索引模型根據 Issue 內容生成。
描述
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce (thanks to @SeeminglyScience)
Environment:
- PowerShell 7.3.6 or higher on up-to-date Windows 10 22H2 x64
- ThreadJob 2.0.3 and Microsoft.PowerShell.ThreadJob 2.1.0
Sporadic race condition exception when accessing $Host.UI.psobject.Properties inside a runspace started with Start-ThreadJob:
-
Start new session:
pwsh -nop -
Paste following:
$event = [System.Threading.ManualResetEvent]::new($false)
$jobs = 1..500 | % {
Start-ThreadJob {
$event = $using:event
$null = $event.WaitOne()
$supportsVT = $Host.UI.psobject.Properties['SupportsVirtualTerminal'].Value
} -StreamingHost $Host
}
Start-Sleep -Milliseconds 500
$null = $event.Set()
$jobs | Receive-Job -AutoRemoveJob -Wait
- If you couldn't repro first time, start new PowerShell session, do not try in the same session.
Steps to reproduce with Pester 5.5.0:
Environment:
- PowerShell 7.3.6 or higher on up-to-date Windows 10 22H2 x64
- Pester 5.5.0
- ThreadJob 2.0.3 and Microsoft.PowerShell.ThreadJob 2.1.0
Sporadic race condition exception when accessing $Host.UI.psobject.Properties inside a runspace started with Start-ThreadJob:
-
Start new session:
pwsh -nop -
Paste following:
1..500 | ForEach-Object {
Start-ThreadJob {
1 | Should -BeExactly 1
$supportsVT = $Host.UI.psobject.Properties['SupportsVirtualTerminal'].Value
} -StreamingHost $Host
} | Wait-Job | Receive-Job | Remove-Job -Force
- If you couldn't repro first time, start new PowerShell session, do not try in the same session.
Expected behavior
There should be no exception.
Actual behavior
InvalidOperation: Cannot index into a null array.
InvalidOperation: Cannot index into a null array.
InvalidOperation: Cannot index into a null array.
InvalidOperation: Cannot index into a null array.
Error details
PS C:\> Get-Error
Exception :
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Cannot index into a null array.
HResult : -2146233087
CategoryInfo : InvalidOperation: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : NullArray
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 26
HistoryId : -1
Line : 1 | Should -BeExactly 1; $supportsVT = $Host.UI.psobject.Properties['SupportsVirtualTerminal'].Value
PositionMessage : At line:1 char:26
+ … eExactly 1; $supportsVT = $Host.UI.psobject.Properties['SupportsVirtu …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
TargetSite : System.Object CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object, System.String)
Message : Cannot index into a null array.
Data : System.Collections.ListDictionaryInternal
Source : Anonymously Hosted DynamicMethods Assembly
HResult : -2146233087
StackTrace :
at CallSite.Target(Closure, CallSite, Object, String)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : InvalidOperation: (:) [], RuntimeException
FullyQualifiedErrorId : NullArray
InvocationInfo :
ScriptLineNumber : 1
OffsetInLine : 26
HistoryId : -1
Line : 1 | Should -BeExactly 1; $supportsVT = $Host.UI.psobject.Properties['SupportsVirtualTerminal'].Value
PositionMessage : At line:1 char:26
+ … eExactly 1; $supportsVT = $Host.UI.psobject.Properties['SupportsVirtu …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
Name Value
---- -----
PSVersion 7.3.6
PSEdition Core
GitCommitId 7.3.6
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Version
ThreadJob 2.0.3 and Microsoft.PowerShell.ThreadJob 2.1.0
Visuals
- 主要語言
- PowerShell
- 星號
- 37
- 分支
- 22
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/ThreadJob 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 48/100
PowerShell/ThreadJob#59 · 1 個 reaction ·
-
enhancement
難度 3/5 1-2 天 新手友好度 56/100
PowerShell/ThreadJob#56 · 1 個 reaction ·
-
Set alias for ThreadJob command(s)可能已有人在做 @kilasuit 於 80 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 20/100
PowerShell/ThreadJob#45 · 1 則留言 ·
-
難度 1/5 1-3 小時 新手友好度 48/100
PowerShell/ThreadJob#44 ·
-
難度 4/5 3-5 天 新手友好度 35/100
PowerShell/ThreadJob#43 ·
查看 PowerShell/ThreadJob 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
Merit-Systems/x402scan#1312 ·
-
難度 2/5 1-3 小時 新手友好度 82/100
developmentseed/titiler-cmr#265 ·
維護者通常 1 天內回覆
-
Insecure Brotli version <1.2.1可能已有人在做 @jamescw19 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 85/100
stac-utils/stac-fastapi-pgstac#438 · 1 個 reaction ·
-
[deliverclient] Remove the unused common/deliverclient package可能已有人在做 @liran-funaro 今天認領。 未關閉code-hygiene
難度 2/5 1-3 小時 新手友好度 72/100
hyperledger/fabric-x-common#236 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
linagora/twake-calendar-side-service#1218 · 1 則留言 ·
維護者通常 1 天內回覆