Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Intermittent exceptions during concurrent custom-rule execution

Đang mở
#2,222 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
32/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp, powershell

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
C#
Star
2.2k
Fork
419
Merge trung bình
17 giờ 27 phút
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PowerShell/PSScriptAnalyzer

Tất cả issue của PowerShell/PSScriptAnalyzer

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.