Skip to content

Use atomic GCC profile counters in coverage builds - #7461

Closed
JinmingHu (Jinming-Hu) wants to merge 1 commit into
Azure:mainfrom
Jinming-Hu:fix-gcc-atomic-coverage-counters
Closed

JinmingHu (Jinming-Hu) wants to merge 1 commit into
Azure:mainfrom
Jinming-Hu:fix-gcc-atomic-coverage-counters

Conversation

@Jinming-Hu

Copy link
Copy Markdown
Member

Summary

Add -fprofile-update=atomic to the existing GNU Debug coverage compiler flags in cmake-modules/AzureCodeCoverage.cmake. This makes coverage-counter updates thread-safe when instrumented SDK code is called concurrently.

This is a candidate fix for intermittent gcovr NegativeHits failures, not a claim that their exact cause has already been established. GCC documents atomic updates as preventing profile corruption in multithreaded applications: https://gcc.gnu.org/onlinedocs/gcc-13.4.0/gcc/Instrumentation-Options.html#index-fprofile-update

Evidence

The same Ubuntu Storage LIVE coverage job failed while processing storage_bearer_token_authentication_policy.cpp.gcda on main and on #7448:

Both logs report negative branch counts. In the PR retry, compilation and ctest succeeded; coverage generation failed.

Scope

  • Only coverage-enabled GNU Debug builds are affected; the existing coverage gate is unchanged.
  • No SDK authentication, public API, or release-build changes.
  • No coverage-file exclusions or suppression of gcovr parsing errors.
  • Separate from Add STG105 Storage features #7448 and based directly on main.

Validation

  • Exercised the CMake helper and confirmed it preserves existing flags and adds the atomic-update flag.
  • Confirmed the coverage-disabled macro leaves compiler flags unchanged.
  • Linux/GCC compilation and the affected ValidateLive Ubu2404_x64_with_unit_test coverage workload are pending CI. Verify the effective compiler flags and successful coverage generation before considering this experiment successful.

Enable -fprofile-update=atomic alongside GCC coverage instrumentation to keep counters consistent under concurrent SDK calls. Keep ordinary builds and gcovr error handling unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
8 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The targeted flag is correctly limited by the existing GNU Debug coverage gate and preserves prior behavior.

0 open findings

What changed in this PR

Adds thread-safe GCC coverage-counter updates to reduce intermittent gcovr profile corruption.

Changes:

  • Adds -fprofile-update=atomic to GNU Debug coverage builds.
  • Documents why atomic counter updates are required.
File Description
cmake-modules/​AzureCodeCoverage.cmake Enables atomic GCC profile-counter updates for coverage instrumentation.

🧠 Review effort: Balanced

@Jinming-Hu

Copy link
Copy Markdown
Member Author

/azp run cpp - storage

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@Jinming-Hu

Copy link
Copy Markdown
Member Author

Closing as redundant: #7459 already merged the equivalent -fprofile-update=atomic coverage change into main (c236cac).

@Jinming-Hu
JinmingHu (Jinming-Hu) deleted the fix-gcc-atomic-coverage-counters branch October 14, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants