Subject: bug#69795: 29.1; cmdproxy.exe exits automatically after executing MSYS2 commands

From: Eli Zaretskii <[email-masked]>
Date: Sun, 17 Mar 2024 08:18:43 +0200

> From: [email-masked]
> Cc: [email-masked]
> Date: Sun, 17 Mar 2024 10:06:13 +0900
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> Before setting PATH, the value is:
> >>   C:\ImageMagick;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\user\AppData\Local\Programs\Python\Python310\;C:\Users\user\AppData\Local\Microsoft\WindowsApps;
> >> Then removing directories other than C:\WINDOWS or descendants:
> >>   C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;
> >
> > I don't understand what you mean by "removing directories other than
> > C:\WINDOWS or descendants".  Why do they need to be removed?  And how
> > did you remove them?
> 
> I removed obviously unrelated pathnames, which are for imagemagick and
> python. They are not supplied by OS. And I removed them by hand.

I don't understand why you did that, but since it doesn't change the
results, we can ignore this aspect.

> > What happens if you change PATH to include the two addition
> > directories, c:\msys64\mingw64\bin\ and c:\msys64\usr\bin, before you
> > start Emacs, and then run GDB from the shell buffer without changing
> > PATH inside the shell buffer?
> 
> Input following command lines on cmd.exe.
>   set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%
>   c:\Emacs\emacs-29.1\bin\emacs-29.1.exe -Q
> And run gdb in shell-mode, then process automatically finished.
> 
> Microsoft Windows [Version 10.0.19045.4170]
> (c) Microsoft Corporation. All rights reserved.
> 
> c:\tmp>set PATH
> set PATH
> PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;C:\ImageMagick;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\user\AppData\Local\Programs\Python\Python310\;C:\Users\user\AppData\Local\Microsoft\WindowsApps;
> PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
> 
> c:\tmp>c:\msys64\mingw64\bin\gdb.exe
> c:\msys64\mingw64\bin\gdb.exe
> GNU gdb (GDB) 13.2
> Copyright (C) 2023 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Type "show copying" and "show warranty" for details.
> This GDB was configured as "x86_64-w64-mingw32".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <https://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
>     <http://www.gnu.org/software/gdb/documentation/>.
> 
> For help, type "help".
> Type "apropos word" to search for commands related to "word".
> (gdb) q
> 
> c:\tmp>
> Process shell finished

Same result.

> > Please also show the contents of these two directories you add to
> > PATH.  Maybe the reason for this is something in those directories.
> 
> Here is output of dir command.

Nothing jumps out as an obvious problem, but you did say that setting
PATH affects this?  How does it affect the problem?  Is there a recipe
where you invoke GDB with a different PATH, and don't see "Process
shell finished" after exiting GDB?  If so, can you show a recipe with
that different PATH?

Btw, why do you add these directories to PATH in the first place?  The
second one is a directory with MSYS executables, so why do you need it
for running GDB?  The first one is for MinGW64 executables, but since
you invoke GDB via n explicit absolute file name, you don't need to
add the directory to PATH.