Why does IIS crash when printing to stderr in Perl?

It drove me crazy. We have IIS (6) and Windows 2008 and ActiveState Perl 5.10. For some reason, when we make a warning or carp, it ends up corrupting the application pool. Of course, this is a pretty big deal, because it means that our errors really cause problems.

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

+2
perl iis
source share
4 answers

Ensure that the IIS and Perl DLLs are associated with the same version of the C runtime library. (Use the depend.exe file or dumpbin / dependents).

To expand: the problem may be that IIS has the FILE * table in one place, and the perl DLL thinks it will be in a slightly different place. When perl is sent to search for the stderr descriptor, it treats random memory as a file descriptor with predictable results.

+2
source share

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 am not sure why you will have this problem. But a few "wild" guesses about the sources for such a problem will be considered by the above code.

(It has been some time since I read the source code for adding files to Win32, but as I recall, the mode → mode plus binmode means that writing to a file from different processes is unlikely to collide, preventing the text from overlapping in the log.)

0
source share

A few suggestions:

  • Make sure the workflow ID has write permission to the directory / file you are writing. I probably will not give however control over C :. Better to make a subdirectory.
  • Write to the event log instead of the file using Win32 :: EventLog
0
source share

Update: I found that this error only occurs when there is a variable in the warning. If the warning is just plain text, no problem. Also, the variable cannot be empty, and it looks like you should have two warnings with non-empty variables in order to get into this error.

0
source share

All Articles