From: JWF on
I've got a continuous integration build server (CruiseControl.NET) running as
a service. It is almost always busy running builds through command line apps
(cmd.exe w/ lots of nested nmakes, cl.exe, link.exe, etc. w/ redirected
output to log files).

The service is running in the context of a domain account so that when a
build is done it is easy to copy the built files to a larger share on one of
our servers.

All of this can crank along for days without problems. Until someone logs
into the PC either locally or through remote terminal services. Sometime
during the login phase, some program involved in the build will die with a
0xc0000142. The build fails, the email is sent alerting folks = all for
nothing because the build didn't really fail. Something about logging into
the PC effectively kills a process that is involved in the build.

I'm guessing there is some kind of race condition where the act of logging
into the PC and creating a new windows station, etc. results in some sort of
death in user32.dll or CreateProcess or something.

We've seen cl.exe, link.exe, midl.exe, nmake.exe all die because of this at
various times. Even cmd.exe can fail with bizarre errors you'd never see
otherwise = like a "cd" command failing. Never the same program as the repro
conditions are pretty hard, but if you want a build to fail, just login to
the box and some part of it will usually die.

The service itself is NOT dying - it is always some new program that is
starting up during the build.

It doesn't matter if the new person logging into the PC is using the same
domain account as what the service is running in or not - doesn't matter.
Both accounts have administrator privs on the PC.

We can repro this on XP Pro SP2 32-bit and XP Pro 64-bit Edition.

I've increased the SharedSection= line in the Windows subsystem key in the
registry as a KB article indicated non-interactive, non-localsystem account
services can run out of desktop heap and fail in bizarre ways.

Extremely frustrating and even getting this far has taken weeks in trying to
solve it.

Any ideas how to stabilize this?

In trying to get a small repro case I have a test service that simply runs
cmd.exe with a test.bat arg and that just runs lots of little processes -
i.e. lots of CreateProcess stuff going on all the time. Setup the service to
crank along, log in and out of the PC a bunch and boom = some process will
die due to c0000142 8 out of 10 times.