You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tom Donovan <To...@tomdonovan.net> on 2007/09/14 20:37:59 UTC

resend: Bug report re: Apache 2.2.6 on Windows

-------- Original Message --------
Subject: Bug report
Date: Fri, 14 Sep 2007 10:27:19 -0400
From: Tom Donovan <To...@tomdonovan.net>
Reply-To: Tom.Donovan@acm.org
To: modperl@perl.apache.org

-------------8<---------- Start Bug Report ------------8<----------
1. Problem Description:

   perl-script handler fails with Apache 2.2.6 on Windows
   due to changes in stdin/stdout/stderr handles in mpm_winnt

   Problem occurs with mod_perl 2.0.3 or with
      current (9/14/2007) SVN trunk.

   Problem is not seen if Apache is started as a single process
      > httpd.exe -X

   This is similar to, but not the same as, Apache bug 43329
     http://issues.apache.org/bugzilla/show_bug.cgi?id=43329
   which concerns the APR 1.2.11 process-creation changes.

   This problem can be avoided if \server\mpm\winnt\mpm_winnt.c
   from Apache 2.2.4 is used - even with APR 1.2.11.
   Note that server\log.c line 411 also needs to be changed to
   work with this older mpm_winnt.

   Failure is at line 128 in modperl_io.c
     (function modperl_io_perlio_override_stdin)
     --------------------------------------------------------
     modperl_io.c - in function modperl_io_perlio_override_stdin
     124        /* open my $oldout, "<&STDIN" or die "Can't dup STDIN:
     125        status = do_open(handle_save, "<&STDIN", 7, FALSE,
     126                         O_RDONLY, 0, Nullfp);
     127        if (status == 0) {
>>> 128            Perl_croak(aTHX_ "Failed to dup STDIN: %" SVf,
     129        }
     ---------------------------------------------------------

2. Used Components and their Configuration:

*** mod_perl version 2.000004

*** using C:\work\mod_perl-trunk\lib\Apache2\BuildConfig.pm

*** Makefile.PL options:
   MP_APR_LIB     => aprext
   MP_COMPAT_1X   => 1
   MP_GENERATE_XS => 1
   MP_LIBNAME     => mod_perl
   MP_USE_DSO     => 1


*** httpd.exe -V
Server version: Apache/2.2.6 (Win32)
Server built:   Sep 14 2007 09:44:55
Server's Module Magic Number: 20051115:5
Server loaded:  APR 1.2.11, APR-Util 1.2.10
Compiled using: APR 1.2.11, APR-Util 1.2.10
Architecture:   32-bit
Server MPM:     WinNT
   threaded:     yes (fixed thread count)
     forked:     no
Server compiled with....
  -D APACHE_MPM_DIR="server/mpm/winnt"
  -D APR_HAS_SENDFILE
  -D APR_HAS_MMAP
  -D APR_HAS_OTHER_CHILD
  -D AP_HAVE_RELIABLE_PIPED_LOGS
  -D DYNAMIC_MODULE_LIMIT=128
  -D HTTPD_ROOT="/apache"
  -D SUEXEC_BIN="/apache/bin/suexec"
  -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
  -D DEFAULT_ERRORLOG="logs/error.log"
  -D AP_TYPES_CONFIG_FILE="conf/mime.types"
  -D SERVER_CONFIG_FILE="conf/httpd.conf"


*** (apr|apu)-config linking info

(apr|apu)-config scripts were not found



*** C:\Perl\bin\perl.exe -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
   Platform:
     osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
     uname=''
     config_args='undef'
     hint=recommended, useposix=true, d_sigaction=undef
     usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED
-DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
     optimize='-MD -Zi -DNDEBUG -O1',
     cppflags='-DWIN32'
     ccversion='12.00.8804', gccversion='', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
     d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
     ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='__int64', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"C:\Perl\lib\CORE"  -machine:x86'
     libpth=\lib
     libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib
odbc32.lib odbccp32.lib msvcrt.lib
     perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib
version.lib odbc32.lib odbccp32.lib msvcrt.lib
     libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl):
   Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
                         PERL_IMPLICIT_SYS PERL_MALLOC_WRAP
                         PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES
                         USE_PERLIO USE_SITECUSTOMIZE
   Locally applied patches:
     ActivePerl Build 822 [280952]
     Iin_load_module moved for compatibility with build 806
     PerlEx support in CGI::Carp
     Less verbose ExtUtils::Install and Pod::Find
     Patch for CAN-2005-0448 from Debian with modifications
     Rearrange @INC so that 'site' is searched before 'perl'
     Partly reverted 24733 to preserve binary compatibility
     MAINT31223 plus additional changes
     31490 Problem bootstraping Win32CORE
     31324 Fix DynaLoader::dl_findfile() to locate .so files again
     31214 Win32::GetLastError fails when first called
     31211 Restore Windows NT support
     31188 Problem killing a pseudo-forked child on Win32
     29732 ANSIfy the PATH environment variable on Windows
     27527,29868 win32_async_check() can loop indefinitely
     26970 Make Passive mode the default for Net::FTP
     26379 Fix alarm() for Windows 2003
     24699 ICMP_UNREACHABLE handling in Net::Ping
   Built under MSWin32
   Compiled at Jul 31 2007 19:34:48
   %ENV:
     PERL_LWP_USE_HTTP_10="1"
   @INC:
     C:/Perl/site/lib
     C:/Perl/lib
     .

*** Packages of interest status:

Apache2            : -
Apache2::Request   : -
CGI                : -
ExtUtils::MakeMaker: -
LWP                : -
mod_perl           : -
mod_perl2          : -


3. This is the core dump trace: (if you get a core dump):

     Stack trace captured with WinDBG debugger
       mod_perl.so built with VC6 from 9/14/2007 SVN trunk

01c4fd04 7c596a7c ntdll!NtTerminateProcess+0xb
01c4fdd0 78007cd8 KERNEL32!ExitProcess+0x72
01c4fddc 78007c60 MSVCRT!exit+0xc0
01c4fdec 28087b6b MSVCRT!exit+0xd
01c4fe40 28083ddf perl58!Perl_my_strlcpy+0x220b
01c4fe58 10007349 perl58!Perl_croak+0x19
01c4fe88 10001ba2 mod_perl!modperl_io_perlio_override_stdin+0xb5
[modperl_io.c @ 128]
01c4fec8 6ff025e8 mod_perl!modperl_response_handler_cgi+0xdb [mod_perl.c
@ 1095]
01c4fee0 6ff02a6f libhttpd!ap_run_handler+0x4e
[C:\work\httpd-2.2.6\server\config.c @ 158]
01c4ff10 6ff12f02 libhttpd!ap_invoke_handler+0x120
[C:\work\httpd-2.2.6\server\config.c @ 372]
01c4ff20 6ff0dc8d libhttpd!ap_process_request+0x50
[C:\work\httpd-2.2.6\modules\http\http_request.c @ 258]
01c4ff34 6ff05eae libhttpd!ap_process_http_connection+0x67
[C:\work\httpd-2.2.6\modules\http\http_core.c @ 184]
01c4ff4c 6ff06237 libhttpd!ap_run_process_connection+0x4e
[C:\work\httpd-2.2.6\server\connection.c @ 43]
01c4ff5c 6ff27400 libhttpd!ap_process_connection+0x4e
[C:\work\httpd-2.2.6\server\connection.c @ 180]
01c4ff80 1020bf53 libhttpd!worker_main+0xec
[C:\work\httpd-2.2.6\server\mpm\winnt\child.c @ 777]
01c4ffb4 7c57b3bc MSVCRTD!_beginthreadex+0x133
01c4ffec 00000000 KERNEL32!BaseThreadStart+0x52


This report was generated by t\REPORT on Fri Sep 14 13:52:24 2007 GMT.

-------------8<---------- End Bug Report --------------8<----------

Note: Complete the rest of the details and post this bug report to
modperl <at> perl.apache.org. To subscribe to the list send an empty
email to modperl-subscribe@perl.apache.org.


Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
William A. Rowe, Jr. wrote:
> 
> is that mod perl is attempting to protect us from ourselves even before
> the fixes went into win32.  Of all of the adjustments in version 2.2.6,
> try backing out only this single effect of the patch, which closed stdin
> on both the parent and child, and please confirm if this alone is enough
> to placate mod_perl?  (This would be patch -R to revert the following.)
> 
> --- httpd/httpd/branches/2.2.x/server/mpm/winnt/mpm_winnt.c	2006/09/15 13:19:25
> 446606
> +++ httpd/httpd/branches/2.2.x/server/mpm/winnt/mpm_winnt.c	2007/08/24 22:04:23

Belay that request :)  I missed something.

I'll follow up with a patch that opens /device/null for stdio/faux-posix
as well as MS filehandles, and shoot that to the list in a bit (along with
post my concept to that other bug, so we can look at all of it.)



Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Tom Donovan wrote:
> 
> -------------8<---------- Start Bug Report ------------8<----------
> 1. Problem Description:
> 
>   perl-script handler fails with Apache 2.2.6 on Windows
>   due to changes in stdin/stdout/stderr handles in mpm_winnt
> 
>   Problem occurs with mod_perl 2.0.3 or with
>      current (9/14/2007) SVN trunk.

>   This is similar to, but not the same as, Apache bug 43329
>     http://issues.apache.org/bugzilla/show_bug.cgi?id=43329
>   which concerns the APR 1.2.11 process-creation changes.
> 
>   This problem can be avoided if \server\mpm\winnt\mpm_winnt.c
>   from Apache 2.2.4 is used - even with APR 1.2.11.

Yes; definately a different problem although a side effect of the same
attempt to fix the issue.  What is interesting

>   Failure is at line 128 in modperl_io.c
>     (function modperl_io_perlio_override_stdin)
>     --------------------------------------------------------
>     modperl_io.c - in function modperl_io_perlio_override_stdin
>     124        /* open my $oldout, "<&STDIN" or die "Can't dup STDIN:
>     125        status = do_open(handle_save, "<&STDIN", 7, FALSE,
>     126                         O_RDONLY, 0, Nullfp);
>     127        if (status == 0) {
>>>> 128            Perl_croak(aTHX_ "Failed to dup STDIN: %" SVf,

is that mod perl is attempting to protect us from ourselves even before
the fixes went into win32.  Of all of the adjustments in version 2.2.6,
try backing out only this single effect of the patch, which closed stdin
on both the parent and child, and please confirm if this alone is enough
to placate mod_perl?  (This would be patch -R to revert the following.)

--- httpd/httpd/branches/2.2.x/server/mpm/winnt/mpm_winnt.c	2006/09/15 13:19:25
446606
+++ httpd/httpd/branches/2.2.x/server/mpm/winnt/mpm_winnt.c	2007/08/24 22:04:23
569541
@@ -1297,6 +1297,9 @@
                                        0, TRUE, DUPLICATE_SAME_ACCESS)) {
                     SetStdHandle(STD_OUTPUT_HANDLE, nullstdout);
                 }
+
+                /* Close the original handle, we used the duplicate */
+                apr_file_close(nullfile);
             }
         }
     }
@@ -1635,6 +1638,9 @@

         /* Set up the listeners */
         get_listeners_from_parent(s);
+
+        /* Done reading from the parent, close that channel */
+        CloseHandle(pipe);

         ap_my_generation = ap_scoreboard_image->global->running_generation;
     }

Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by Tom Donovan <To...@tomdonovan.net>.
Michael Lackhoff wrote:
> On 18.09.2007 15:47 William A. Rowe, Jr. wrote:

> Hmm, I don't understand this, so I cannot say how serious it could be.
> My question is: Should I stick with 2.0.59 or upgrade with a patched
> 2.0.61/2.2.6?
> This is a production server and the change log lists quite a few
> security fixes for the new versions.
> As long as all that could be broken is logging, I think I would like to
> upgrade or could the change effect other parts as well (security)?
> 
> - Michael
> 
I don't think this patch is appropriate for production use, even if it 
does work with 2.0.61.

My intent was just to (temporarily) bypass the mod_perl/FastCGI problems 
to continue testing the rest of the changes in 2.2.6.  I certainly 
wouldn't use it in production.

The effects of this patch, however, would be confined to error logging, 
presuming Apache 2.0 even starts with the patch.

-tom-

Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Michael Lackhoff wrote:
> On 18.09.2007 15:47 William A. Rowe, Jr. wrote:
> 
> Hmm, I don't understand this, so I cannot say how serious it could be.
> My question is: Should I stick with 2.0.59 or upgrade with a patched
> 2.0.61/2.2.6?
> This is a production server and the change log lists quite a few
> security fixes for the new versions.
> As long as all that could be broken is logging, I think I would like to
> upgrade or could the change effect other parts as well (security)?

Read the security fixes.  Primarily, unix-environmental changes.  Nothing
high severity if you trust the authors of web content dispatched by your
server.

Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by Michael Lackhoff <mi...@lackhoff.de>.
On 18.09.2007 15:47 William A. Rowe, Jr. wrote:

> Yes, of course.  However in the second case, you do not have an inheritable
> file handle.  apr_file_dup simply dups the handle in the current process,
> so the patch can't possibly have the desired effect.
> 
> There is a real concern; under what conditions would stderr_log not be
> initialized.  *therein* lies the bug.

Hmm, I don't understand this, so I cannot say how serious it could be.
My question is: Should I stick with 2.0.59 or upgrade with a patched
2.0.61/2.2.6?
This is a production server and the change log lists quite a few
security fixes for the new versions.
As long as all that could be broken is logging, I think I would like to
upgrade or could the change effect other parts as well (security)?

- Michael



Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Tom Donovan wrote:
> Michael Lackhoff wrote:
>> On 23.12.37378 20:59 Tom Donovan wrote:
>>
>>> 1. Problem Description:
>>>
>>>   perl-script handler fails with Apache 2.2.6 on Windows
>>>   due to changes in stdin/stdout/stderr handles in mpm_winnt
>>>
>>>   Problem occurs with mod_perl 2.0.3 or with
>>>      current (9/14/2007) SVN trunk.
>>
>> I noticed the same problem with Apache 2.0.61.

This is consistent at least.  In fact the same changes were applied
to both.

>>>   This problem can be avoided if \server\mpm\winnt\mpm_winnt.c
>>>   from Apache 2.2.4 is used - even with APR 1.2.11.
>>>   Note that server\log.c line 411 also needs to be changed to
>>>   work with this older mpm_winnt.
>>
>> I would like to try this but since I am not a C programmer, can you say
>> what the changed line in log.c should look like?
>> And is there a similar fix for 2.0.61? I would prefer to stay with the
>> 2.0.x branch for the time being.
>>
>> - Michael
> 
> The change I made in 2.2.6 was to line 411 in server\log.c
> --------------------------------------
> CHANGED:
> 
>     rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p);
> 
> TO:
> 
>     if (stderr_log)
>         rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p);
>     else
>         rv = apr_file_dup(&stderr_log, s_main->error_log, stderr_p);
> --------------------------------------
> 
> Note the '&' character before 'stderr_log' in the call to apr_file_dup.
>  This differs from the call to apr_file_dup2, and it's easy to miss.

Yes, of course.  However in the second case, you do not have an inheritable
file handle.  apr_file_dup simply dups the handle in the current process,
so the patch can't possibly have the desired effect.

There is a real concern; under what conditions would stderr_log not be
initialized.  *therein* lies the bug.

> The line to change in server\log.c for version 2.0.61 is line 413.
> You must also replace server\mpm\winnt\mpm_winnt.c with the one from
> Apache 2.0.59.  I haven't tried this with Apache 2.0 and AFAIK nobody
> else has, so please test carefully.
> 
> Also note that this reverses the changes which improved piped logging
> for 2.2.6 (2.0.61).

And, I believe, breaks piped logging processes again, although this would
be noticed in 2.2.6 not 2.0.61, because we launch a pipe log process in
2.0, while we launch a pipe log cmd shell in 2.2.


Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by Tom Donovan <To...@tomdonovan.net>.
Michael Lackhoff wrote:
> On 23.12.37378 20:59 Tom Donovan wrote:
> 
>> 1. Problem Description:
>>
>>   perl-script handler fails with Apache 2.2.6 on Windows
>>   due to changes in stdin/stdout/stderr handles in mpm_winnt
>>
>>   Problem occurs with mod_perl 2.0.3 or with
>>      current (9/14/2007) SVN trunk.
> 
> I noticed the same problem with Apache 2.0.61.
> 
>>   This problem can be avoided if \server\mpm\winnt\mpm_winnt.c
>>   from Apache 2.2.4 is used - even with APR 1.2.11.
>>   Note that server\log.c line 411 also needs to be changed to
>>   work with this older mpm_winnt.
> 
> I would like to try this but since I am not a C programmer, can you say
> what the changed line in log.c should look like?
> And is there a similar fix for 2.0.61? I would prefer to stay with the
> 2.0.x branch for the time being.
> 
> - Michael

The change I made in 2.2.6 was to line 411 in server\log.c
--------------------------------------
CHANGED:

     rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p);

TO:

     if (stderr_log)
         rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p);
     else
         rv = apr_file_dup(&stderr_log, s_main->error_log, stderr_p);
--------------------------------------

Note the '&' character before 'stderr_log' in the call to apr_file_dup. 
  This differs from the call to apr_file_dup2, and it's easy to miss.

The line to change in server\log.c for version 2.0.61 is line 413.
You must also replace server\mpm\winnt\mpm_winnt.c with the one from 
Apache 2.0.59.  I haven't tried this with Apache 2.0 and AFAIK nobody 
else has, so please test carefully.

Also note that this reverses the changes which improved piped logging 
for 2.2.6 (2.0.61).

-tom-

Re: resend: Bug report re: Apache 2.2.6 on Windows

Posted by Michael Lackhoff <mi...@lackhoff.de>.
On 23.12.37378 20:59 Tom Donovan wrote:

> 1. Problem Description:
> 
>   perl-script handler fails with Apache 2.2.6 on Windows
>   due to changes in stdin/stdout/stderr handles in mpm_winnt
> 
>   Problem occurs with mod_perl 2.0.3 or with
>      current (9/14/2007) SVN trunk.

I noticed the same problem with Apache 2.0.61.

>   This problem can be avoided if \server\mpm\winnt\mpm_winnt.c
>   from Apache 2.2.4 is used - even with APR 1.2.11.
>   Note that server\log.c line 411 also needs to be changed to
>   work with this older mpm_winnt.

I would like to try this but since I am not a C programmer, can you say
what the changed line in log.c should look like?
And is there a similar fix for 2.0.61? I would prefer to stay with the
2.0.x branch for the time being.

- Michael