Re: W2K cmd.exe loses ability to start processes - memory leaks

T

Ted Davis

I have a baffling occasional problem.

My machine loses the ability to start processes.
If I use Task Manager (right click in unused part of startbar to start),
I can see Mem Usage: increase from about 57000K to 115000K in 390116K.
The problem is not cleared by logging out - a reboot clears it.
I have stopped all startup processes on my machine and most services to
simplify the situation.

My conjecture is that CreateProcess is leaking some resource.
Any suggestions?

The 142 I occasionally see might be
C:/PF/MVS/VC98/INCLUDE/WINERROR.H:#define ERROR_BUSY_DRIVE 142L
The text on that message makes that seem doubtful
The system cannot perform a JOIN or SUBST at this time.
I found nothing relevant on that in MSDN.

Some failures this morning allowed me to construct the following model
script which fails on my machine. I have indented each line by 2 spaces
to allow line wrap to be shown:

@echo off
:: loop.bat
::
:: Dummy to cause my machine to seize - VM use increases. Machine stops.
::
:: Failures are mainly:
:: The system cannot execute the specified process
:: and occasionally
:: a MessageBox The application failed to initialize properly 0xC0000142
::
:: When Who What
:: 2003-07-05 W.Briscoe Original
echo hello > foo
:: Fails after 2130 echoed. Occasionally writes:
:: "The process tried to write to a non existent pipe"
for /L %%v in (1,1,32767) do echo %%v & echo F | xcopy /y foo bar > nul
::
:: Fails after 4227 echoed. Does not stop. Run with "loop 2>&1 | more"
:: for /L %%v in (1,1,32767) do echo %%v & attrib +r foo
::
:: Does not fail - internal command
:: for /L %%v in (1,1,32767) do echo %%v & copy /y foo bar > nul

Any thoughts on that occasional "The process tried to write to a non
existent pipe"?

You are using Windows. Reboot it when it does that. Get used to it -
it doesn't go away in XP.

Figure on rebooting
Win3.x - several time a day
Win9x - at least once a day
NT4 - every couple of days
W2k - once or twice a week
XP - about every ten days, unless you use it heavily.

Of course, if you do odd things in a CMD prompt, you may have to
reboot after every experiment.

If you don't like rebooting, don't use Windows for anything serious or
unusual.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my .sig in the body)
 
H

Herb Martin

You are using Windows. Reboot it when it does that. Get used to it -
it doesn't go away in XP.

Figure on rebooting
Win3.x - several time a day
Win9x - at least once a day
NT4 - every couple of days
W2k - once or twice a week
XP - about every ten days, unless you use it heavily.

This is bad advice or based on running BUGGY services and drivers,
usually not from Microsoft - at least for all the NT4 class machine.

I never re-boot NT4 (NT3.51), W2K+, or XP just because.

If you must, you are running some add-on that is buggy or have
bad hardware (heat perhaps?), etc.


Ted Davis said:
You are using Windows. Reboot it when it does that. Get used to it -
it doesn't go away in XP.

Figure on rebooting
Win3.x - several time a day
Win9x - at least once a day
NT4 - every couple of days
W2k - once or twice a week
XP - about every ten days, unless you use it heavily.

Of course, if you do odd things in a CMD prompt, you may have to
reboot after every experiment.

If you don't like rebooting, don't use Windows for anything serious or
unusual.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my
..sig in the body)
 
T

Ted Davis

This is bad advice or based on running BUGGY services and drivers,
usually not from Microsoft - at least for all the NT4 class machine.

I never re-boot NT4 (NT3.51), W2K+, or XP just because.

If you must, you are running some add-on that is buggy or have
bad hardware (heat perhaps?), etc.

The worst offender among programs that mess up NT/W2K/XP is CMD.EXE -
a Microsoft product. It is sometimes possible to recover, but
rebooting is sure and faster than trying, and usually failing, to fix
a basically unstable OS. Well, it may not be the OS so much as the
GUI, but MS insists that the GUI is part of the OS, though anyone with
any understanding of computer operating systems knows better. On the
other hand, they have tied the two so closely together, that once the
GUI has been started, you can't realistically stop and restart it.

Saying that when the OS crashes, it's due to bad software is just
saying that the OS is so fragile and unstable that it can't recover
from a program that goes wild. One *expects* that the OS can survive
that sort of stuff and prevent one rogue or crashed program from
damaging others. With MS operating systems, one is disappointed.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my .sig in the body)
 
H

Herb Martin

I never re-boot NT4 (NT3.51), W2K+, or XP just because.
The worst offender among programs that mess up NT/W2K/XP is CMD.EXE -
a Microsoft product. It is sometimes possible to recover, but

Not for me and I keep 2-4 of them open all of the time. CMD.exe
has probably NEVER locked my machine in fact.

If you are having a lot of trouble with Win2000 (or NT4 post SP5),
or for that matter Linux or NetWare, then you aren't yet really an
admin -- sorry but these things are pretty easy to keep running without
re-booting if you FIX problems instead of just re-booting by rote.
Saying that when the OS crashes, it's due to bad software is just
saying that the OS is so fragile and unstable that it can't recover
from a program that goes wild. One *expects* that the OS can survive

No one said that -- I said bad add-on's meaning services and drivers
as opposed to applications. Since services and drivers run (generally)
as part of the OS, there is little protecting against bad ones.
 
W

Walter Briscoe

In message <[email protected]> of Sat, 5 Jul 2003
23:52:04 in microsoft.public.win2000.cmdprompt.admin, Herb Martin
Not for me and I keep 2-4 of them open all of the time. CMD.exe
has probably NEVER locked my machine in fact.

If you are having a lot of trouble with Win2000 (or NT4 post SP5),
or for that matter Linux or NetWare, then you aren't yet really an
admin -- sorry but these things are pretty easy to keep running without
re-booting if you FIX problems instead of just re-booting by rote.


No one said that -- I said bad add-on's meaning services and drivers
as opposed to applications. Since services and drivers run (generally)
as part of the OS, there is little protecting against bad ones.

What curious responses to a request for help!
I shall cut payment by 5% :)

I did some more work.
The problem is unlikely to be due to CMD.EXE. I cobbled a process
together which did a specified command a specified number of times using
CreateProcess. It failed in a similar way to my batch file.

I started W2K in safe mode with command prompt. I was able to run my
original batch file twice in succession.
It took 23 minutes to do timethis loop.bat | tail.

I infer my problem is due to differences in the way memory is allocated
and likely to be a matter of memory allocation configuration.
I found nothing relevant.

I am surprised "The process tried to write to a non existent pipe" got
no interest. I can only infer that Ted was recovering from an excessive
celebration of the declaration of independence of his country from my
adopted country. :)
 
T

Ted Davis

I am surprised "The process tried to write to a non existent pipe" got
no interest. I can only infer that Ted was recovering from an excessive
celebration of the declaration of independence of his country from my
adopted country. :)

I get it all the time - sometimes it is due to a syntax error, but
more often it isn't. Sometimes closing the CMD window and starting
over will clear it, but once it has occurred in a window for reasons
other than a syntax error, that session is poisoned and can't be
relied on to work properly: last week I kept running into the pipe
error, and afterwards, whenever I killed an executable program with
^C, CMD popped up the "Terminate batch file (y/n)" prompt (sometimes
twice on the same line). A 'y' response returned an "'y' is not
recognized as an internal or external command, operable program or
batch file" error.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my .sig in the body)
 
T

Ted Davis

How do you get from using 2-4 cmd prompts 100% of the time to
"don't use it"? Reading problem?

An emphasis problem: that should have been *use*. I have noticed that
Windows will attempt to teach you what is safe to do and what, though
well within the documented limits, isn't - some people learn quickly
and don't push the envelope. On the other hand, I have tasks that
should be done under Unix/Linux, which my boss is afraid of, and
therefore have to push CMD pretty hard - some of my batch loops run a
number of remote access utilities in a 1024 pass loop (almost - I
don't poke the router or broadcast addresses).
The above just shows you have a poor grasp of English and logic --
less unstable COULD mean that something which is unstable once
every millions years is now making it to once per billion years; it is
NOT such an admission relative to other operating systems; it in fact
makes no claim reference OTHER operating systems.

However, MS makes the claims while acknowledging that the earlier
Windows versions were quite unstable, as anyone who ever tired to do
something like run a server under Win3.1 (or anything else requiring
high uptime and heavy usage) can testify. This fixes the context. One
might also mention the built-in 47 day crash trigger in NT4 (rollover
in the uptime counter causes instability) that wasn't noticed for
years because not enough people could keep it up long enough to reach
that point enough times to notice the pattern.

I will admit that I have an NT machine that has been up since the last
power failure ... I think it's still up - I haven't used it; and I
have an NT server that has been up longer than that ... but we can't
use the automatic flashcard reader/copier ... it (a batch file) went
nuts a month ago but isn't enough to force rebooting the main Web
server. But fear not, once the fall begins, something critical will
fail soon enough and I'll have to reboot it.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my .sig in the body)
 
M

Marty List

Ted Davis said:
On Sun, 6 Jul 2003 13:25:53 -0500, "Herb Martin" <[email protected]>

However, MS makes the claims while acknowledging that the earlier
Windows versions were quite unstable, as anyone who ever tired to do
something like run a server under Win3.1 (or anything else requiring
high uptime and heavy usage) can testify. This fixes the context. One
might also mention the built-in 47 day crash trigger in NT4 (rollover
in the uptime counter causes instability) that wasn't noticed for
years because not enough people could keep it up long enough to reach
that point enough times to notice the pattern.

I will admit that I have an NT machine that has been up since the last
power failure ... I think it's still up - I haven't used it; and I
have an NT server that has been up longer than that ... but we can't
use the automatic flashcard reader/copier ... it (a batch file) went
nuts a month ago but isn't enough to force rebooting the main Web
server. But fear not, once the fall begins, something critical will
fail soon enough and I'll have to reboot it.


T.E.D. ([email protected] - e-mail must contain "T.E.D." or my
..sig in the body)


I don't know about everyone else, but I'm finding humor in this idiot's
ramblings.
 
W

Walter Briscoe

In message <[email protected]> of Sun, 6 Jul
2003 10:15:01 in alt.msdos.batch.nt, Ted Davis
I get it all the time - sometimes it is due to a syntax error, but
more often it isn't. Sometimes closing the CMD window and starting
over will clear it, but once it has occurred in a window for reasons
other than a syntax error, that session is poisoned and can't be
relied on to work properly: last week I kept running into the pipe
error, and afterwards, whenever I killed an executable program with
^C, CMD popped up the "Terminate batch file (y/n)" prompt (sometimes
twice on the same line). A 'y' response returned an "'y' is not
recognized as an internal or external command, operable program or
batch file" error.

I find it depressing that this thread produced so much bile/vitriol.
I would not like these groups to go the way of alt.msdos.batch.

On "Terminate batch file (y/n)", I have so far succeeded in stopping
without zapping. My conceptual model is that two threads simultaneously
want input. Only one is going to get what I type. Typing a 'y' line
twice is usually enough to silence that prompt. I just failed to show
the problem!

In may last message, I said:
I started W2K in safe mode with command prompt. I was able to run my
original batch file twice in succession.
It took 23 minutes to do timethis loop.bat | tail.
I have since done more work where I used Task Manager to monitor memory
usage. My loop.bat leaks in safe mode at a much lower rate than it does
in "normal" mode. It still leaks. My `exec_cmd 32767 "attrib +r foo"`
leaks at the same rate as "loop.bat" in "normal" mode but does not leak
in safe mode.
 
B

Bill Stewart

Marty List said:
I don't know about everyone else, but I'm finding humor in this idiot's
ramblings.

I do indeed find this curious -- I have a home network of two Windows 2000
machines, and I never reboot unless 1) a software installation requests it
because it has updated a system driver, or 2) I have a power outage. No
"stability" problems there.

At work, I have a network of 5 Windows NT 4.0 servers, 3 Windows 2000
servers, and 75 Windows 2000 workstations. They don't ever need reboots
either, except for the same two reasons stated above.

My guess is that one will find all kinds of stability problems with a
misconfigured operating system or flaky hardware. As an example, I once set
up a training lab of 20 PCs running Red Hat Linux 7.0. On one particular
machine, Red Hat kept crashing (standard installation). It didn't crash
with Windows 2000. Replacing the system memory fixed it. On another
machine, I managed to mess something up in the configuration, and it
started crashing too. I performed the standard format and reload, and it
worked fine after that.

I always first suspect misconfiguration or hardware problems when someone
claims that Windows 2000 or XP is "unstable."
 
O

olivier

-----Original Message-----

contain "T.E.D." or my
..sig in the body)


I don't know about everyone else, but I'm finding humor in this idiot's
ramblings.



.

huummm, by the way, what was the subject first? :)))
 
M

Mark Zbikowski \(MSFT\)

This will occasionally happen if a user happens to start two CMD's in the
same window. START /B is the culprit.

This would also explain his two "Terminate Batch File? (Y/N)" as well
since the ^C is handed to all win32 processes attached to that console.

The writing to non-existent pipe occurs when the destination of the pipe
exits. So, if you're doing:

(echo foo & sleep 60 & echo bar) | head -1

the first foo will be sent to head, head will read it, output it, and exit.
When the second echo executes, it gets the non-existent pipe error.

HTH
 
H

Herb Martin

This will occasionally happen if a user happens to start two CMD's in the
same window. START /B is the culprit.

This would also explain his two "Terminate Batch File? (Y/N)" as well
since the ^C is handed to all win32 processes attached to that console.

The writing to non-existent pipe occurs when the destination of the pipe
exits. So, if you're doing:

(echo foo & sleep 60 & echo bar) | head -1

the first foo will be sent to head, head will read it, output it, and exit.
When the second echo executes, it gets the non-existent pipe error.

(Not arguing with you, just wishing clarification): I though /B only
sent Ctrl-Break to the background, and not Ctrl-C?

That's what the help says; and it is more or less what my (Win2000)
machine seems to do??? I use /B to run BIND (DNS server) invisibibly
when testing from command line -- to be specific:

start /separate /b named -f

Ctrl-Break will stop it, but Ctrl-C which would stop it if it were
foreground
(does in fact) will NOT stop the background named....
 
W

Walter Briscoe

In message <[email protected]> of Thu, 10 Jul 2003
15:41:15 in alt.msdos.batch.nt, "Mark Zbikowski (MSFT)"
I infer that Mark is referring to my question about the mechanism
involved in "The process tried to write to a non existent pipe"
This will occasionally happen if a user happens to start two CMD's in the
same window. START /B is the culprit.

This would also explain his two "Terminate Batch File? (Y/N)" as well
since the ^C is handed to all win32 processes attached to that console.

The writing to non-existent pipe occurs when the destination of the pipe
exits. So, if you're doing:

(echo foo & sleep 60 & echo bar) | head -1

the first foo will be sent to head, head will read it, output it, and exit.
When the second echo executes, it gets the non-existent pipe error.

HTH
It does help in that it puts a meaning on the error.
The original failing code (run in a W2K SP3) cmd.exe .bat file was
echo hello > foo
:: Fails after 2130 echoed. Occasionally writes:
:: "The process tried to write to a non existent pipe"
for /L %%v in (1,1,32767) do echo %%v & echo F | xcopy /y foo bar > nul
I could see a race condition producing that response.
i.e. xcopy starts and exits and echo F finds a broken pipe.
That looks like a bug to this naive soul!

Later: I decided to investigate. I wondered why I had used "> nul"
rather than "/q". The reason is that "/Q Does not display file names
while copying.". It does not suppress " File(s) copied". In
investigating that, I discovered that
Does bar specify a file name
or directory name on the target
(F = file, D = directory)? F
only happens on the first iteration through the loop.

That time bar does not exist; subsequently it does and the prompt is not
given. There IS a race condition! xcopy may complete before echo is
tried. THAT is now analysed :)

That still leaves the original question (slightly recast).
What might explain the following consuming memory and eventually failing
to start a process after just over 4k iterations?

if exist foo del /f foo
if exist bar del /f bar
echo hello > foo
copy foo bar > nul
:: Fails after 4243 echoed.
::
for /L %%v in (1,1,2147483647) do echo %%v & xcopy /y foo bar > nul || goto done

My hypothesis is that something in my W2K SP3 registry is causing a
memory of each process to be retained for some debugging purpose.
I have no notion what it is! :-(
 
M

Mark Zbikowski \(MSFT\)

I'd have to check with the console folks about the differences in sending
^Break vs ^C. CMD traps them both. Of course your experience lends
credence to the fact that what Win32 console believes it the current input
process is the one who receives the ^Break.
 
H

Herb Martin

I have simplified my system to run nothing other than the following -
all from Redmond.
System Idle Process
System
smss.exe
winlogon.exe
services.exe
svchost.exe providing Remote Procedure Call
svchost.exe providing Com+ Event System, Network Connections,
Removable Storage, Remote Access Connection Manager, System
Event Notification and Telephony
MSTask.exe providing Task Scheduler
lsass.exe providing IPSEC Policy Agent and Security Accounts
Manager
csrss.exe
Explorer.exe
cmd.exe
xcopy.exe

Are you sure you can get by without the Workstation and Server
services (yes their main job is share access and serving but they
do other things)?

Maybe some other necessary service is missing....
I view AV as a cure worse than the disease. (Like mercury for syphilis.)

I used to be of that opinion too, but then the virus/trojan authors started
abusing the holes in so many programs or services we pretty much
require on the net.
 
J

Jonathan de Boyne Pollard

WB> I wrote a simple process which used the CreateProcess API to
WB> start a process in a loop. That failed in a similar fashion.

What was the handle count of the process at the point of failure ? How much
virtual memory had it allocated ?
 
Top