Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Source file allowlist on recorder TargetAllowlist ignored #3371

Closed
ranweiler opened this issue Aug 1, 2023 · 1 comment
Closed

Source file allowlist on recorder TargetAllowlist ignored #3371

ranweiler opened this issue Aug 1, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ranweiler
Copy link
Member

ranweiler commented Aug 1, 2023

Summary

The source file allowlist most-directly configured on coverage recorders is ignored, and only the source allowlist owned by the debuginfo cache is used for source file filtering. This is more of a confusing API flaw than an active bug, and is due to the debuginfo cache being a later addition.

Found by @Porges.

Context

The DebugInfoCache owns an Arc<Allowlist>. This is used as a source file allowlist, and determines what binary coverage locations should be measured, given the source files they were defined in. However, CoverageRecorder owns a TargetAllowlist, which is composed of two Allowlist values: one for modules, one for source files. But this TargetAllowlist is now only used for its TargetAllowlist.module field, and its source_files field is ignored by the recorder implementations.

For users of the coverage crate, these two nominal source file allowlists can confusingly diverge, via normal use of the debuginfo_cache() and allowlist() builder methods on CoverageRecorder. It is reasonable for a caller to expect that the TargetAllowlist.source_files field is used, but it never will be.

Solutions

The debuginfo cache really is coupled to its source file Allowlist, because the cached analysis is a function of that list. However, the CoverageRecorder still needs to have an additional Allowlist to use for module-level filtering. Furthermore, since debuginfo analysis can be very expensive, we probably don't want to just invalidate the cache (and re-run analysis to create a new one) if the recorder source file allowlist is modified.

The least confusing / best performing change is probably to rename CoverageRecorder.allowlist() (and related fields) to module_allowlist(), and have it accept an Allowlist (instead of a TargetAllowList).

The TargetAllowlist may still be worth keeping in some form after this, but might not.

AB#162997

@ranweiler ranweiler added the bug Something isn't working label Aug 1, 2023
@Porges
Copy link
Member

Porges commented Aug 1, 2023

Removal of TargetAllowList and associated changes are addressed in #3368

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants