'Safe handle has been closed' when stopping debugger while in a dynamicparam section in v2.2
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues, especially the pinned issues.
Exception report
Last 200 Keys:
<omitted irrelevant keystrokes>
f o o Spacebar - b Tab
### Exception
System.ObjectDisposedException: Safe handle has been closed
at System.Threading.WaitHandle.WaitMultiple(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext, Boolean WaitAll)
at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext)
at Microsoft.PowerShell.PSConsoleReadLine.ReadKey()
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)
Screenshot
N/A
Environment data
PS Version: 5.1.19041.1320
PS HostName: Visual Studio Code Host
PSReadLine Version: 2.2.0-beta4
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 227
BufferHeight: 28
Steps to reproduce
- Use VS Code with PowerShell Preview 2021.12.0 extension
- Create a function with dynamic parameters, e.g.:
function foo
{
[CmdletBinding()]
param ()
dynamicparam
{
$DynParams = [Management.Automation.RuntimeDefinedParameterDictionary]::new()
$DynParam = [Management.Automation.RuntimeDefinedParameter]::new(
'bar',
[string],
[Collections.ObjectModel.Collection[System.Attribute]]::new()
)
$DynParams.Add($DynParam.Name, $DynParam)
return $DynParams
}
}
- Put a breakpoint within the
dynamicparam
block and start an interactive session - Invoke the dynamic parameter with
foo -
and hit <tab> - Debugger stops in the
dynamicparam
block, as expected - Stop the debugger with <Ctrl-F5>
- Integrated console returns, but shows error message
Expected behavior
No exception
Actual behavior
Error shown
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (11 by maintainers)
Top Results From Across the Web
src/sysprep.psm1 0.0.13 - PowerShell Gallery
Configures kernel debugging for the VHD(X) being created. EnableDebugger takes a single argument which specifies the debugging transport to use.
Read more >PowerShell basics - Notes from a DevSecOps consultant
1 2. $myArrayOfInts = $myArrayOfInts + 5 # now contains 1,2,3,4 & 5! ... cmdlet 5 > file # Send debug output to...
Read more >B Securing Communication - Access Manager
Using the secure-sockets layer (SSL) protocol helps prevent eavesdropping and ... TLS 1.2 is fully supported since incoming traffic is terminated on the ......
Read more >Tool Guide
and other Huawei trademarks are trademarks of Huawei Technologies Co., ... Every effort has been made in the ... 2 Downloading Client Tools....
Read more >Diff - refs/tags/android-6.0.1_r42^! - platform/external/jetty
The relevant packages which were merged into the single src directory are: ... doesn't stop after the jetty + server is stopped +...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s not a supported scenario.
PSConsoleReadLine.ReadLine
is a static method, but the operations are all around a singleton ofPSConsoleReadLine
. Reentry of the PSReadLine means corrupting the text buffer of the singleton and more, so it won’t work.Is it possible to identify that we are re-entering the
ReadLine
method? If so, how about use the old legacy readline in that rare scenario?It’d be nice to have a better error message here, but this is still a case of needing re-entrance in PSReadLine. Now that attach to process works, I think that’s the best way to debug argument completers, tab completion in general, and PSReadLine key handlers.