PowerShell / PowerShell/vscode-powershell

'Safe handle has been closed' when stopping debugger while in a dynamicparam section in v2.2

Aperta
#3,751 14 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@andyleejordan ci sta già lavorando.

Dal 3/2/2022.

Area-Debugging Issue-Bug
Lingua principale
TypeScript
Stelle
1.9k
Fork
548
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Prerequisites
  • 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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.