tags:

views:

390

answers:

4

This has been driving me crazy. We have IIS (6) and windows 2008 and ActiveState Perl 5.10. For some reason whenever we do a warn or a carp it eventually corrupts the app pool. Of course, that's a pretty big deal since it means that our errors actually cause problems.

This happened with the previous version of Perl (5.8) and Windows (2003) and IIS (5.) Anyway, basically I put in a carp or a warn and I get an error message and then some garbage text. Any thoughts?

A: 

Try adding the following to the top of your scripts:

BEGIN {
    open STDERR, '>> c:/iisError.log'
        or  die "Can't write to c:/issError.log: $!\n";
    binmode STDERR;
}

I'm not sure why you would have this problem. But several "wild" guesses as to sources for such a problem would be addressed by the above code.

(It has been a while since I read the source code for appending to files in Win32, but, as I recall, the >> mode plus binmode means that writes to the file from different processes are unlikely to collide, preventing overlapping text in the log.)

tye
For some reason this won't work. It clearly creates the file that I ask it to log to, but it still goes to the old log file. I tried to even force it by doing print STDERR 'foo' and it still prints to the old file.
Frew
A: 

A couple of suggestions:

  1. Make sure that the id of the worker process has write permission to the directory/file you are writing. I probably wouldn't give it full control of C:, though. Better to make a sub-directory.
  2. Write to the event log instead of a file using Win32::EventLog
tvanfosson
+2  A: 

Check to make sure that IIS and the perl DLL are linked with the same version of the C runtime library. (Use depends.exe or dumpbin /dependents).

To expand: the problem may be that IIS has its FILE* table in one place, and the perl DLL thinks it's going to be in a slightly different place. When perl goes to find the stderr handle, it treats random memory as a file handle, with predictable results.

Sam Mikes
Any idea where iis is installed? I can't seem to find anything...
Frew
A: 

Update: I discovered that this error only happens when you have a variable in the warn. If the warn is just regular text there are no issues. Also, the variable cannot be empty and it looks like you have to have two warns with nonempty variables to hit the bug.

Frew