Skip to content

Make TSF initialization fully fallible#19958

Merged
lhecker merged 1 commit intomainfrom
dev/lhecker/tsf-init-checks
Mar 10, 2026
Merged

Make TSF initialization fully fallible#19958
lhecker merged 1 commit intomainfrom
dev/lhecker/tsf-init-checks

Conversation

@lhecker
Copy link
Copy Markdown
Member

@lhecker lhecker commented Mar 10, 2026

Apparently, on some (internal) variants of Windows TF_CategoryMgr
can exist while TF_DisplayAttributeMgr is absent. This is likely
a variant configuration error, but we shouldn't crash anyway.

Closes MSFT-61309810

Copy link
Copy Markdown
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Nice/Clean HRESULT transformation 😊

Comment on lines +76 to +79
RETURN_IF_FAILED_EXPECTED(CoCreateInstance(CLSID_TF_CategoryMgr, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(_categoryMgr.addressof())));
RETURN_IF_FAILED_EXPECTED(CoCreateInstance(CLSID_TF_DisplayAttributeMgr, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(_displayAttributeMgr.addressof())));
// There's no point in calling TF_GetThreadMgr. ITfThreadMgr is a per-thread singleton.
_threadMgrEx = wil::CoCreateInstance<ITfThreadMgrEx>(CLSID_TF_ThreadMgr, CLSCTX_INPROC_SERVER);
RETURN_IF_FAILED_EXPECTED(CoCreateInstance(CLSID_TF_ThreadMgr, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(_threadMgrEx.addressof())));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious, why'd you use the EXPECTED variant here? Looks like that just doesn't record failures to the error log.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Since these calls are known to fail on some Windows versions, they're expected to fail and so we don't need to log them, right?

@lhecker lhecker merged commit 30b1456 into main Mar 10, 2026
20 checks passed
@lhecker lhecker deleted the dev/lhecker/tsf-init-checks branch March 10, 2026 20:31
@github-project-automation github-project-automation bot moved this to To Cherry Pick in 1.24 Servicing Pipeline Mar 11, 2026
@github-project-automation github-project-automation bot moved this to To Cherry Pick in 1.25 Servicing Pipeline Mar 11, 2026
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.24 Servicing Pipeline Mar 12, 2026
DHowett pushed a commit that referenced this pull request Mar 12, 2026
Apparently, on some (internal) variants of Windows `TF_CategoryMgr`
can exist while `TF_DisplayAttributeMgr` is absent. This is likely
a variant configuration error, but we shouldn't crash anyway.

Closes MSFT-61309810

(cherry picked from commit 30b1456)
Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgnOd-c
Service-Version: 1.24
@DHowett DHowett moved this from To Cherry Pick to Cherry Picked in 1.25 Servicing Pipeline Mar 12, 2026
DHowett pushed a commit that referenced this pull request Mar 12, 2026
Apparently, on some (internal) variants of Windows `TF_CategoryMgr`
can exist while `TF_DisplayAttributeMgr` is absent. This is likely
a variant configuration error, but we shouldn't crash anyway.

Closes MSFT-61309810

(cherry picked from commit 30b1456)
Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgnOg_4
Service-Version: 1.25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Cherry Picked
Status: Cherry Picked

Development

Successfully merging this pull request may close these issues.

3 participants