Paul Sobey wrote:

> Guys,
> 
> I have a threaded service written in perl which spawns a child process
> and sends STDOUT/STDERR to disk via windows anonymous pipes. The service
> works perfectly in test, and has now gone live across several servers in
> our company. The service uses Win32::API to call the api CreateProcess
> function, needed to explicitly pass in the pipe handles for
> STDOUT/STDERR. Occasionally, the service throws an exception at the
> point where CreateProcess is called. It's very intermittant, and I can't
> really see a pattern, but I have found that changing the code even
> slightly - for instance adding a print statement just before
> CreateProcess is called - is often enough to make the service behave
> properly. This implies to me that I've got some funny race condition,
> but my knowledge of C and the API doesn't go far enough to know where to
> start looking. Each server has between 5-25 services using this code,
> and it doesn't seem to be load related. It's never all the services on
> one box that have a problem, just one or two, the others behaving
> properly at the same time.
> 
> I can't post a sample script that fails, because I can't make it fail in
> test, but the routines in question are encapsulated below. Can anyone...
> 
> a) see anything silly I'm doing wrong
> b) sugest how I might try to get further debugging info?
> c) say whether inclusion of Win32::Daemon and/or threads may have an
> impact?
> 
> One of our C# developers noted that if you are passing pointers to
> unmanaged code from C# you need to tell C# to pin the memory locations,
> or the garbage collector will clean them up. Does perl behave similarly?
> 
> The error reported in the eventlog at the time of the crash is:
> 
> Reporting queued error: faulting application perl.exe, version
> 5.8.1.807, faulting module kernel32.dll, version 5.2.3790.0, fault
> address 0x0001202e.

Can you get by without the pipe and do something simpler with a file
and Win32::Process ? :

use Win32::Process;

my $pObj;
my $file = "C:\\test.log";

Win32::Process::Create($pObj, "$ENV{WINDIR}\\system32\\cmd.exe",
  "cmd /C dir 2>&1 >$file", 0, NORMAL_PRIORITY_CLASS, "C:\\") or
  die "Create: $! ($^E)";

open IN, $file or die "open $file: $! ($^E)";
print <IN>;
close IN;


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to