GetAppLocalTempDirectory leaks a RoInitialize call

Open Beginner friendly
#1,333 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp

Research direction

Start in lib/utils/utils.cpp at Microsoft::Applications::Events::GetAppLocalTempDirectory and inspect the RoInitialize call and its surrounding control flow. Read the linked RoInitialize guidance, then verify that successful initialization is properly balanced and that Application Verifier no longer reports AVRF_STOP_THREADPOOL_DIRTY_COM_STATE.

Written by the indexing model from the issue text.

Description

bug

In Microsoft::Applications::Events::GetAppLocalTempDirectory (lib/utils/utils.cpp), we have this block of code:

auto hr = RoInitialize(RO_INIT_MULTITHREADED) /* Ignoring result from call toRoInitialize as either initialzation is successful, or else already * initialized and it should be ok to proceed in both the scenarios */ UNREFERENCED_PARAMETER(hr);

If you call RoInitialize without a matching call to RoUninitialize, you leak the com initialization on this thread. See the guidance at https://learn.microsoft.com/en-us/windows/win32/api/roapi/nf-roapi-roinitialize:

Each successful call to RoInitialize, including those that return S_FALSE, must be balanced by a corresponding call to RoUninitialize.

This is caught by Application Verifier as AVRF_STOP_THREADPOOL_DIRTY_COM_STATE.

Dominant language
C
Stars
102
Forks
66
Avg merge
3d 10h
Merged PRs (30d)
10

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/cpp_client_telemetry

All issues in microsoft/cpp_client_telemetry

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.