microsoft / microsoft/wil

ResultException::what behaves incorrectly

Open
#303 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
3k
Forks
300
Avg merge
19h 12m
Merged PRs (30d)
1

Description

It appears that it returns an empty string, at least in my particular case, on non-English Windows 10 system (Visual Studio Build Tools 2019).

The GetFailureLogString part actually works fine:

https://github.com/microsoft/wil/blob/3e2ee372dcbbe77977934fbe0c58ff8ceb0236ee/include/wil/result_macros.h#L2639-L2644

I can get the full report from the created string, starting with the drive letter, e. g. "G:\\Test...".

The odd things start with this conversion from wchar_t to char array:

https://github.com/microsoft/wil/blob/3e2ee372dcbbe77977934fbe0c58ff8ceb0236ee/include/wil/result_macros.h#L2646-L2647

In this newly created messageA string Instead of the drive letter I get the null terminating character, the rest of it appears to be fine, e. g. its contents are - "(null terminating character here):\\Test...". Because this string starts with the null terminating character now, the subsequent call of strlen(messageA) returns zero, and nothing valuable is written to the buffer:

https://github.com/microsoft/wil/blob/3e2ee372dcbbe77977934fbe0c58ff8ceb0236ee/include/wil/result_macros.h#L2648

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.

Research direction

Start in include/wil/result_macros.h at the GetFailureLogString and ResultException::what code around lines 2639-2648, focusing on the wchar_t-to-char conversion and subsequent strlen call. Reproduce the behavior on a non-English Windows system or inspect the existing conversion path; done means what() preserves the full failure message instead of returning an empty string.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.