Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Intermittent exceptions during concurrent custom-rule execution

Aperta
#2,222 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
32/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, powershell

Direzione di ricerca

Start from how Invoke-ScriptAnalyzer runs external/custom rules concurrently (AstVisitor2 and $ScriptBlockAst.Visit) on Windows PowerShell 5.1, using the reported Visit NRE and collection-modified exceptions as the failure mode. Trace the custom-rule execution path and any shared visitor or AST state; done means those intermittent errors no longer appear on the same sources while default and custom rules still run.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce


...\PSScriptAnalyzer-Run.ps1" -Path C:\_work\1\s -Recurse -Settings C:\_work\1\.gdn\rs\psscriptanalyzer\63df5559-3449-4d0b-a8b9-8c97aa98fe3b.ruleset -IgnorePattern .gdn -IncludeDefaultRules -RecurseCustomRulePath -BuildInCustomRules SDLRules -OutputFilePath C:\_work\1\.gdn\.r\psscriptanalyzer\001\psscriptanalyzer.sarif

Expected behavior

Executing PSScriptAnalyzer without any errors

Actual behavior

A customer is intermittently seeing errors from "Invoke-ScriptAnalyzer" while PSScriptAnalyzer runs external SDL rules:

Exception calling "Visit" with "1" argument(s):
"Object reference not set to an instance of an object."

They have also seen:

Exception calling "Visit" with "1" argument(s):
"Collection was modified; enumeration operation may not execute."

The affected rules use a PowerShell class derived from "AstVisitor2" and call "$ScriptBlockAst.Visit($customVisitor)". The problem is intermittent: the same source can fail in one run and pass when rerun. PSScriptAnalyzer reports the exception as a non-terminating error and the process still exits with code 0.

Environment data

Environment: Windows PowerShell 5.1 and PSScriptAnalyzer 1.19.1.

Is this a known concurrency issue in PSScriptAnalyzer’s external-rule execution path or in "Ast.Visit()" under Windows PowerShell 5.1?

Lingua principale
C#
Stelle
2.2k
Fork
423
Merge medio
17h 27m
PR unite (30g)
14

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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.

Altre issue di PowerShell/PSScriptAnalyzer

Tutte le issue di PowerShell/PSScriptAnalyzer

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.