Skip to content

Fix crash when user cancels Windows Hello dialog (nullptr from e.what()) - #202

Merged
Branden Bonaby (bbonaby) merged 1 commit into
mainfrom
fixCrashOnClosingHelloDialog_2
Apr 22, 2026
Merged

Fix crash when user cancels Windows Hello dialog (nullptr from e.what())#202
Branden Bonaby (bbonaby) merged 1 commit into
mainfrom
fixCrashOnClosingHelloDialog_2

Conversation

@SohamDas2021

Copy link
Copy Markdown
Collaborator

When exceptions cross the VTL0/VTL1 boundary, the exception object's message pointer can become nullptr because VTL0 heap memory is not accessible from VTL1. Calling std::string(e.what()) or strlen(e.what()) on a nullptr triggers an access violation that fast-fails the host process.

This was reproducible with HostAppUserBound (Create Key -> Cancel) and HostAppUserBoundSignVerify (Sign -> Cancel) sample apps.

Fix: Add a safe_what() helper in both userboundkey.vtl1.cpp (3 sites) and userboundkey.vtl0.cpp (5 sites) that returns a fallback string when e.what() is nullptr.

Note: This is distinct from the fix in PR #201 which addressed incorrect HRESULT mapping of KeyCredentialStatus enum values. That fix ensured the cancel error is reported as a real failure HRESULT; this fix hardens the catch blocks that log the error before re-throwing.

When exceptions cross the VTL0/VTL1 boundary, the exception object's
message pointer can become nullptr because VTL0 heap memory is not
accessible from VTL1. Calling std::string(e.what()) or strlen(e.what())
on a nullptr triggers an access violation that fast-fails the host process.

This was reproducible with HostAppUserBound (Create Key -> Cancel) and
HostAppUserBoundSignVerify (Sign -> Cancel) sample apps.

Fix: Add a safe_what() helper in both userboundkey.vtl1.cpp (3 sites)
and userboundkey.vtl0.cpp (5 sites) that returns a fallback string
when e.what() is nullptr.

Note: This is distinct from the fix in PR #201 which addressed incorrect
HRESULT mapping of KeyCredentialStatus enum values. That fix ensured
the cancel error is reported as a real failure HRESULT; this fix hardens
the catch blocks that log the error before re-throwing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bbonaby
Branden Bonaby (bbonaby) merged commit 2991284 into main Apr 22, 2026
15 checks passed
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.

2 participants