Re: Mysterious script crash in win2k and ActivePerl
by Mr. Muskrat (Canon) on Dec 13, 2002 at 16:31 UTC
|
Try sending all errors to a file instead of the console.
Something like should do the trick:
BEGIN {
$|++;
open(STDERR, ">>", "mysterious_errors.txt");
}
The >> is so that you append new errors to the file instead of overwriting it each time your program is run.
Also add error checking with something like: do_something_with(@my_args) or die("Couldn't so_something_with ", $!); | [reply] [d/l] [select] |
|
I'm not redirecting STDERR yet. I'll add that, but I think it's a Windows level error, so I doubt I'll see anything there. Still, it's worth a try.
| [reply] |
Re: Mysterious script crash in win2k and ActivePerl
by ibanix (Hermit) on Dec 13, 2002 at 16:28 UTC
|
Hi john,
For starters, do you have strict and warnings enabled? You should always be using those.
If you could post some code (always the best thing to do!) then we might be able to help more. Also, why not output your debug statements to a file, so you can read what happens just before it crashes?
Cheers,
ibanix
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo; | [reply] [d/l] |
|
while($buf=~/(.*\n)/g) {
print DEBUG "doing <$1>\n";
${$Con{$fh}}{getline}($fh,$1);
last unless $Con{$fh}; # it's possible that the connection can b
+e deleted while there's still something in the buffer
}
if($Con{$fh}) {
($this->{_})=$buf=~/([^\n\r]*)$/s;
if(length($this->{_}) > 10000) {
${$Con{$fh}}{getline}($fh,$this->{_});
($this->{_})='';
}
}
The problem was that the connection was closed while there was still a line in the buffer. The if($Con{$fh}) tests for that condition.
john | [reply] [d/l] |
Re: Mysterious script crash in win2k and ActivePerl
by gmpassos (Priest) on Dec 14, 2002 at 00:38 UTC
|
Well, very mysterious!
First, what is your Perl version?
If you are usign Perl 5.8.0, disable the signal ALARM:
$SIG{ALARM} = undef ;
to avoid some wrong signal from the OS. I don't know if you need this for 5.6.0+ too! Well, this problem with alarm is very specific.
I saw that you uses sockets. Don't forget to close a socket after use it, or at least lose the $variable with the socket. Because the system, specially on Win32, has a limit for sockets to be opned.
You have to monitore the memory used by the process too! Maybe it wasn't coleting the garbage of unused variables and objects!
If you don't need the prompt window, run your script using the wperl.exe! This way doesn't open a console (pipe) for the process, and was 1 thing less to create problems!
Good luck! ;-P
Graciliano M. P.
"The creativity is the expression of the liberty". | [reply] [d/l] |
|
It's 5.6.1 -- i'll try $SIG{ALARM}=undef; just because I don't know what else to try.
My first guess was that sockets weren't being closed, or were being closed twice. I wrote a bunch of code to check that everything was getting tidied up and it is.
It uses 100 megs of RAM (according to the task manager), but almost all of that is in two big hashes. The only recycling will be in the socket objects which come and go.
Maybe I'll try wperl -- couldn't hurt.
Thanks for trying.
john
| [reply] |
Re: Mysterious script crash in win2k and ActivePerl
by batkins (Chaplain) on Dec 13, 2002 at 20:31 UTC
|
try running the script from the command line. you'll be able to see any errors. | [reply] |
|
The batch file runs from the command line. There's nothing to see -- the command prompt window is gone when I come back.
| [reply] |
|
well, then go to the command line and type
myscript.bat or whatever its name is.
| [reply] |
|
|
Re: Mysterious script crash in win2k and ActivePerl
by batkins (Chaplain) on Dec 14, 2002 at 12:12 UTC
|
hmmm, are you SURE you're running the script from the command line? do you run cmd and then execute the cript? because if you are, the window shouldn't really ever close.
but anyway, redirecting STDERR is probably your best bet:
open(LOG, "+>log.txt");
*STDERR = *LOG;
*STDOUT = *LOF; # just in case some errors go to STDOUT
...
| [reply] [d/l] |