Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#251 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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. Version 18.11.2 fixed the issue reported there. 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 show that losing the initialization byte, rather than losing probe data, is what makes the module disappear from the report:

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"

Losing the initialization byte hides the data loss. 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.

主要语言
C#
星标
126
派生
17
平均合并
1 小时 15 分钟
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/codecoverage 的其他 Issue

查看 microsoft/codecoverage 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。