Subject: Re: bug#10674: 24.0.92; cmdproxy.exe fork-bomb

From: Eli Zaretskii <[email-masked]>
Date: Mon, 06 Feb 2012 19:50:05 +0200

> Date: Mon, 06 Feb 2012 15:29:37 +0000
> From: Simon Morgan <[email-masked]>
> CC: [email-masked]
> 
> > If indeed cmdproxy spawns itself endlessly, then the first suspect is
> > this code in cmdproxy.c:
> >
> >    if (!SearchPath (NULL, argv[0], ".exe", sizeof (path), path,&progname)
> >        || !GetShortPathName (path, path, sizeof (path))
> >        || stricmp (modname, path) != 0)
> >      {
> >        /* We are being used as a helper to run a DOS app; just pass
> > 	 command line to DOS app without change.  */
> >        /* TODO: fill in progname.  */
> >        if (spawn (NULL, GetCommandLine (), dir,&rc))
> > 	return rc;
> >        fail ("Could not run %s\n", GetCommandLine ());
> >      }
> >
> > Are you able to run cmdproxy under a debugger and see what is going on
> > here?  If so, please tell what are argv[0], path, and modname just
> > before the call to `spawn' (assuming my guess is correct, and cmdproxy
> > really calls `spawn' in this snippet).
> 
> Okay so I managed to get cmdproxy running under gdb without much trouble 
> so here is what you asked for:
> 
> http://pastie.org/3327496

Thanks.  For the record, I reproduce that here:

  C:\emacs-24.0.92\bin>gdb cmdproxy.exe
  GNU gdb (GDB) 7.3.1
  Copyright (C) 2011 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 "mingw32".
  For bug reporting instructions, please see:
  <http://www.gnu.org/software/gdb/bugs/>...
  Reading symbols from c:\emacs-24.0.92\bin\cmdproxy.exe...done.
  (gdb) break 565
  Breakpoint 1 at 0x401f3f: file cmdproxy.c, line 565.
  (gdb) r
  Starting program: c:\emacs-24.0.92\bin\cmdproxy.exe
  [New Thread 4636.0x11e0]

  Breakpoint 1, main (argc=1, argv=0x5e2c18) at cmdproxy.c:565
  565           if (spawn (NULL, GetCommandLine (), dir, &rc))
  (gdb) p argv[0]
  $1 = 0x5e2b51 "c:\\emacs-24.0.92\\bin\\cmdproxy.exe"
  (gdb) p path
  $2 = "c:\\emacs-24.0.92\\bin\\cmdproxy.exe\000\000\000\000\000\000\000c\001\000\001\000\000\000\000\177\000\000\000ÕV\000\000\060ü(\000@Wpwhý(\000\064ý(\000v\arw\000\000\210\000\000\000\000\000\000\000\210\000ð‡\210\000Ê¸gwð‡\210\000\000\000\210\000\000\000\210\000Ê¸gwð‡\210\000xý(\000 \027rw8\001\210\000\004\027rwÿ\003ew\000\000\210\000\000\000\210\000\000\000\000\000\000\000\210\000\000\000^\000\000\000\001\001Dý(\000\000\000^\000\\þ(\000Õqlw\027.*\000þÿÿÿ\004\027rwš«mw\000\000\210\000c\000\000P"...
  (gdb) p modname
  $3 = "c:\\emacs-24.0.92\\bin\\cmdproxy.exe\000^\000\000\000^\000¨\016^\000¨\016^\000\001\000\000\000\000\000^\000@þ(\000í\033rw8\001^\000Ñ\033rwÇ\000ew\000\000\000\000\000\000^\000¨\016^\000þÿÿÿ\200\000\000\000ú›m\001\fþ(\000a\000\000P\230þ(\000Õqlw·/*\000þÿÿÿÑ\033rwú›mw\000\000^\000a\000\000P¨\016^\000¨\016^\000¨þ(\000\200ôÊv\000\000^\000\000\000\000\000‰ôÊv–¨•\003\004\000\000\000¬\016^\000¨\016^\000Êúfw\"\020iwÿÿÿÿ$\000\000\000"...
  (gdb)

It sounds like SearchPath fails.  Does it help to add
c:\emacs-24.0.92\bin to your Path?

> I've also discovered that cmdproxy only seems to do the whole infinite 
> respawn thing if I run it in the emacs bin directory.

But then how come it happens for you in customize-browse?  Did you
invoke Emacs in the emacs bin directory?  If so, what happens if you
invoke it from a different directory?