Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug caused by #16592 #16624

Merged
merged 1 commit into from
Jan 31, 2024
Merged

Fix a bug caused by #16592 #16624

merged 1 commit into from
Jan 31, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jan 30, 2024

#16592 passes the return value of GetEnvironmentStringsW directly
to the hstring constructor even though the former returns a
double-null terminated string and the latter expects a regular one.

This PR fixes the issue by using a basic strlen() loop to compute
the length ourselves. It's still theoretically beneficial over
the previous code, but now it's rather bitter since the code isn't
particularly short anymore and so the biggest benefit is gone.

Closes #16623

Validation Steps Performed

  • Validated the env string in a debugger ✅
    It's 1 character shorter than the old til::env string.
    That's fine however, since any HSTRING is always null-terminated
    anyways and so we get an extra null-terminator for free.
  • wt powershell works ✅

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree. labels Jan 30, 2024
@DHowett DHowett enabled auto-merge (squash) January 30, 2024 23:39
@DHowett DHowett merged commit c669afe into main Jan 31, 2024
19 of 20 checks passed
@DHowett DHowett deleted the dev/lhecker/16623-env-regression branch January 31, 2024 00:16
DHowett pushed a commit that referenced this pull request Jan 31, 2024
#16592 passes the return value of `GetEnvironmentStringsW` directly
to the `hstring` constructor even though the former returns a
double-null terminated string and the latter expects a regular one.

This PR fixes the issue by using a basic strlen() loop to compute
the length ourselves. It's still theoretically beneficial over
the previous code, but now it's rather bitter since the code isn't
particularly short anymore and so the biggest benefit is gone.

Closes #16623

## Validation Steps Performed
* Validated the `env` string in a debugger ✅
  It's 1 character shorter than the old `til::env` string.
  That's fine however, since any `HSTRING` is always null-terminated
  anyways and so we get an extra null-terminator for free.
* `wt powershell` works ✅

(cherry picked from commit c669afe)
Service-Card-Id: 91719861
Service-Version: 1.18
DHowett pushed a commit that referenced this pull request Jan 31, 2024
#16592 passes the return value of `GetEnvironmentStringsW` directly
to the `hstring` constructor even though the former returns a
double-null terminated string and the latter expects a regular one.

This PR fixes the issue by using a basic strlen() loop to compute
the length ourselves. It's still theoretically beneficial over
the previous code, but now it's rather bitter since the code isn't
particularly short anymore and so the biggest benefit is gone.

Closes #16623

## Validation Steps Performed
* Validated the `env` string in a debugger ✅
  It's 1 character shorter than the old `til::env` string.
  That's fine however, since any `HSTRING` is always null-terminated
  anyways and so we get an extra null-terminator for free.
* `wt powershell` works ✅

(cherry picked from commit c669afe)
Service-Card-Id: 91719863
Service-Version: 1.20
DHowett pushed a commit that referenced this pull request Jan 31, 2024
#16592 passes the return value of `GetEnvironmentStringsW` directly
to the `hstring` constructor even though the former returns a
double-null terminated string and the latter expects a regular one.

This PR fixes the issue by using a basic strlen() loop to compute
the length ourselves. It's still theoretically beneficial over
the previous code, but now it's rather bitter since the code isn't
particularly short anymore and so the biggest benefit is gone.

Closes #16623

## Validation Steps Performed
* Validated the `env` string in a debugger ✅
  It's 1 character shorter than the old `til::env` string.
  That's fine however, since any `HSTRING` is always null-terminated
  anyways and so we get an extra null-terminator for free.
* `wt powershell` works ✅

(cherry picked from commit c669afe)
Service-Card-Id: 91719862
Service-Version: 1.19
@mjpraxis
Copy link

mjpraxis commented Feb 5, 2024

@lhecker @DHowett Any chance that this could be a fix in v19 and rolled out quickly?
Or is v20 just around the corner?

@zadjii-msft
Copy link
Member

@mjpraxis this was already rolled out in v1.19.10302.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.
Projects
Development

Successfully merging this pull request may close these issues.

[1.18, 1.19, 1.20] wt $COMMAND is **very broken**
4 participants