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

Terminal failed to start if "C:\Program.exe" exists #4061

Closed
everything411 opened this issue Dec 26, 2019 · 7 comments · Fixed by #4172
Closed

Terminal failed to start if "C:\Program.exe" exists #4061

everything411 opened this issue Dec 26, 2019 · 7 comments · Fixed by #4172
Assignees
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Priority-1 A description (P1) Product-Conpty For console issues specifically related to conpty Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@everything411
Copy link

Environment

Windows build number: Microsoft Windows NT 10.0.18363.0

Windows Terminal version: Version: 0.7.3451.0

A program named "C:\Program.exe" by myself

Here is the source code of C:\Program.exe

#include <windows.h>
int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nShowCmd)
{
    MessageBox(NULL, "C:\\Program.exe Executed!", "Bug", MB_OK);
    return 0;
}

my profile

        {
            "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
            "hidden": false,
            "name": "Debian",
            "fontFace": "等距更纱黑体 SC",
            "source": "Windows.Terminal.Wsl"
        },

Steps to reproduce

rename the exe to "Program.exe" and place it at C:\ then run Windows Terminal

Expected behavior

Windows Terminal starts normally

Actual behavior

C:\Program.exe is executed. And after it exits, Windows Terminal exit with an error

捕获

捕获

捕获3

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Dec 26, 2019
@Luuk34
Copy link

Luuk34 commented Dec 26, 2019

Annotation 2019-12-26 111125
Happens when starting WSL and 'C:\Program.exe' exists.

It does not matter which exe is there, i created a copy of sqlite3.exe and named it c:\program.exe

@everything411
Copy link
Author

Annotation 2019-12-26 111125
Happens when starting WSL and 'C:\Program.exe' exists.

It does not matter which exe is there, i created a copy of sqlite3.exe and named it c:\program.exe

This is a really old bug that have existed in
Windows for a long time. Not only windows terminal but also many other softwares are affected by this :(

the cause is the space in the folder name "Program Files". if the path is not quoted , some apis(such as CreateProcess) cannot deal with it very well.

For example,for C:\Program Files\Example Dir\Exe File.exe, it will try these following paths and the following contents is passed to as arguments. so if a program named "C:\Program.exe" exists, it will executed instead of the proper one.

  • C:\Program.exe
  • C:\Program Files\Example.exe
  • C:\Program Files\Example Dir\Exe.exe
  • C:\Program Files\Example Dir\Exe File.exe

@everything411
Copy link
Author

#include <windows.h>
char str[1000];
int WinMain(
  HINSTANCE hInstance,
  HINSTANCE hPrevInstance,
  LPSTR     lpCmdLine,
  int       nShowCmd
)
{
    MessageBox(NULL, lpCmdLine, "Bug", MB_OK);
    return 0;
}

try this and ..
捕获

@Luuk34
Copy link

Luuk34 commented Dec 28, 2019

#include <windows.h>
char str[1000];
int WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
MessageBox(NULL, lpCmdLine, "Bug", MB_OK);
return 0;
}

try this and ..

This is much better than the Chinese?? pictures.
Who can read Chinees today? (not many @microsoft.com I guess... 😁)

@zadjii-msft zadjii-msft added the Product-Conpty For console issues specifically related to conpty label Dec 30, 2019
@zadjii-msft zadjii-msft added this to the 21H1 milestone Dec 30, 2019
@zadjii-msft zadjii-msft added Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. labels Dec 30, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Dec 30, 2019
@zadjii-msft zadjii-msft added the Priority-1 A description (P1) label Dec 30, 2019
@zadjii-msft
Copy link
Member

If I'm reading this thread correctly, this sounds like we'll need to make sure to properly escape the path to conhost.exe in CreatePseudoConsole implementation. Thanks for finding this and investigating!

@eryksun
Copy link

eryksun commented Dec 30, 2019

If you have a qualified path, you should be using the lpApplicationName parameter of CreateProcessW instead of searching the command line. But the image path in lpCommandLine should still be quoted properly for applications that parse their command line and expect the command to be parsed as argv[0]. Of course, it can just be "conhost.exe" in the command line if this executable, which you control, doesn't try to find the executable file via argv[0] (yuck).

@DHowett-MSFT DHowett-MSFT added Help Wanted We encourage anyone to jump in on these. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Jan 6, 2020
@DHowett-MSFT DHowett-MSFT self-assigned this Jan 9, 2020
@ghost ghost added the In-PR This issue has a related PR label Jan 9, 2020
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Jan 11, 2020
DHowett-MSFT pushed a commit that referenced this issue Jan 11, 2020
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR labels Jan 11, 2020
DHowett-MSFT pushed a commit that referenced this issue Jan 24, 2020
Fixes #4061.

Co-authored-by: Michael Niksa <[email protected]>
(cherry picked from commit 2712e41)
@ghost
Copy link

ghost commented Jan 27, 2020

🎉This issue was addressed in #4172, which has now been successfully released as Windows Terminal Preview v0.8.10261.0.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Priority-1 A description (P1) Product-Conpty For console issues specifically related to conpty Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants