PowerShell / PowerShell/vscode-powershell

Infinite loop when closing PowerShell process while being attached by the Visual Studio Code debugger

Offen
#4,887 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Area-Debugging Issue-Bug
Vorherrschende Sprache
TypeScript
Sterne
1.9k
Forks
548
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

An error occurred while running the REPL loop:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)   
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Console.PsrlReadLine.InvokePSReadLine(CancellationToken cancellationToken) in D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Console\PsrlReadLine.cs:line 48
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 92
--- End of stack trace from previous location ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeReadLine(CancellationToken cancellationToken) in D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 1248
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(CancellationToken cancellationToken) in D:\a\_work\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 1149
Screenshot

N/A

Environment data
PS Version: 7.4.0
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.4
PSReadLine EditMode: Windows
OS: 10.0.22621.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 30
Steps to reproduce
  1. Install PowerShell extension in Visual Studio Code (version v2024.0.0)
  2. Prepare the launch.json with the following content:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "PowerShell Attach to Host Process",
            "type": "PowerShell",
            "request": "attach"
        }
    ]
}
  1. Start a new instance of the PowerShell
  2. Attach to it using the Visual Studio Code
  3. Wait till the debugger attaches to the process
  4. Close the PowerShell
Expected behavior

No exception

Actual behavior

When the PowerShell process being currently attached by the Visual Studio debugger is closed, the infinite exception loop occurs.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den Fehler mit der angehängten launch.json-Konfiguration zu reproduzieren: Hänge den Visual Studio Code PowerShell-Debugger an und schließe dann den PowerShell-Prozess. Lies die gemeldeten Stacktrace-Stellen in PsrlReadLine.cs, SynchronousTask.cs und PsesInternalHost.cs, um die Behandlung des Herunterfahrens nachzuverfolgen. Die Aufgabe ist abgeschlossen, wenn das Schließen des angehängten Prozesses weder eine Ausnahme noch eine Endlosschleife erzeugt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell, typescript, vscode
Bereich
developer-experience, devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.