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

Coverage buffer that loses its initialization byte is reported as a passing run with an empty report (line-rate="1")

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

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
52/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
Lĩnh vực
testing-qa, tooling

Hướng nghiên cứu

Start by tracing SharedMemoryStream.IsInitialized() through the collector path described in the issue, including the guards around AddPackage, AddStream, and PopulateCoverageStatus. Reproduce the offset-0 corruption using the harness and results linked from issue #232. Done means an uninitialized module buffer is made visible as an anomaly rather than producing a passing empty report that satisfies coverage thresholds.

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

Mô tả

Package: Microsoft.Testing.Extensions.CodeCoverage 18.11.2 (the latest at the time of writing)
Runtime: .NET 8 and .NET 10 hosts, Linux x64, xunit.v3 3.2.2 on Microsoft.Testing.Platform
Context: split out of #232, which 18.11.2 fixed. The harness and full results are in this comment.

Summary

If a module's coverage buffer loses its initialization byte, the run is reported as Passed! and the cobertura report is 178 bytes, with line-rate="1" over an empty <packages />. A coverage threshold passes it, so the data loss goes unnoticed.

Cause

The byte at offset 0 of the buffer is read by SharedMemoryStream.IsInitialized(). It gates whether a module enters the report at all: if (logStream.IsInitialized()) guards AddPackage, AddStream and PopulateCoverageStatus. Truncating the buffer zeroes that byte, and the host's flush writes only the indices where a probe fired, so index 0 is never restored.

Two runs isolate it to that byte, rather than to the data loss itself:

what was done to the buffer cobertura
write a single zero byte to offset 0; file length and all 1,356 probe bytes left intact 178 bytes, line-rate="1"
truncate to 0, re-extend to the original length, then set offset 0 back to 1 337,297 bytes, line-rate="0.027"

The direction matters. When the flag survives, the report shows a low rate that honestly reflects the destroyed data, and any coverage threshold catches it. When the flag is lost, the report shows a perfect rate over zero lines, which every threshold passes.

Suggestion

The collector created the buffer and handed it to the host, so a module whose buffer comes back uninitialized is an anomaly it can detect, not a normal skip. Logging a warning at that point, or failing the coverage step, would make this loss visible.

Ngôn ngữ chính
C#
Star
125
Fork
17
Merge trung bình
1 giờ 15 phút
Pull request đã merge (30 ngày)
2

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 microsoft/codecoverage

Tất cả issue của microsoft/codecoverage

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.