You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Aleksandr Guidrevitch <pi...@tut.by> on 2003/12/04 00:13:25 UTC

help, $apr->param hangs

Prerequesities:

1. Opera browser
    Version 7.21 Final    
    Build 480    
    Platform Linux    
    System i686, 2.4.20-alt5-up    
    Qt library 3.1.1    
    Java    No Java Runtime Environment installed

2. custom PerlHandler
....
sub handler ($$) {
    ...
    $apr = Apache::Request->new($r);
    warn $apr->param();
    ...
}

3. some web form with enctype="multipart/form-data" 
(application/x-www-form-urlencoded works ok)

When posting this form first time - everything works ok.
The $apr->param hangs (seems for infinite time)
only and only when I press "reload" button in Opera
(i.e. repost the multipart/form-data). If I press back and then press 
form's
submit button - everything works ok. Both Konqueror 3.1.0 and Mozilla 1.5
handle the "reload" button ok.

It looks like Opera sends broken data when pressing "Reload" and
reposting a form with enctype="multipart/form-data".
It doesn't matter how to fix Opera, but how can I work this situation 
around ?
Set timeout via signals ? Or there is another well-known solution ?

Thanks,
Alex

----------------------------------
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.18-alt7-smp, archname=i386-linux-thread-multi
    uname='linux mash.office.altlinux.ru 2.4.18-alt7-smp #1 smp thu jun 
6 11:43:56 msd 2002 i686 unknown unknown gnulinux '
    config_args='-des -Darchname=i386-linux -Dd_dosuid -Ud_csh 
-Duseshrplib -Dlibperl=libperl.so.5.8 -Doptimize=-pipe -Wall -O2 
-fexpensive-optimizations -march=i586 -mcpu=i686 -Dinstallprefix=/usr 
-Dprefix=/usr -Dprivlib=/usr/lib/perl5 
-Darchlib=/usr/lib/perl5/i386-linux -Dvendorprefix=/usr 
-Dvendorlib=/usr/lib/perl5/vendor_perl 
-Dvendorarch=/usr/lib/perl5/vendor_perl/i386-linux 
-Dsiteprefix=/usr/local -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.0 
-Dsitearch=/usr/local/lib/perl5/site_perl/5.8.0/i386-linux 
-Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dcf_by=ALT 
Linux Team -Dmyhostname=localhost -Dperladmin=root@localhost 
-Dinc_version_list=5.6.1 5.6.0  -Dpager=/usr/bin/less -isR -Di_shadow 
-Di_syslog -Dusethreads -Duseithreads -Duselargefiles -Ui_db -Di_gdbm 
-Di_ndbm -Di_sdbm -Ui_odbm'
    hint=recommended, useposix=true, d_sigaction=define
    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='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing 
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-pipe -Wall -O2 -fexpensive-optimizations -march=i586 
-mcpu=i686',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing 
-I/usr/include/gdbm'
    ccversion='', gccversion='3.2.1 (ALT Linux, build 3.2.1-alt2)', 
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
    perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
    libc=/lib/libc-2.2.6.so, so=so, useshrplib=true, libperl=libperl.so.5.8
    gnulibc_version='2.2.6'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES 
PERL_IMPLICIT_CONTEXT
  Built under linux
  Compiled at Dec 30 2002 15:10:05
  @INC:
    /usr/lib/perl5/i386-linux
    /usr/lib/perl5
    /usr/local/lib/perl5/site_perl/5.8.0/i386-linux
    /usr/local/lib/perl5/site_perl/5.8.0
    /usr/local/lib/perl5/site_perl
    /usr/lib/perl5/vendor_perl/i386-linux
    /usr/lib/perl5/vendor_perl
    /usr/lib/perl5/vendor_perl




-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Hi Frank


[ag@aguidrevitch tauction]$ grep -P '.*= 3' <strace.log
...
accept(16, {sa_family=AF_INET, sin_port=htons(38587), 
sin_addr=inet_addr("127.0.0.1")}, [16]) = 3
alarm(300)                              = 300
alarm(0)                                = 300
read(4, "package Test::Handler;\n\nuse "..., 4096) = 3418
read(8, "# Generated from XSLoader.pm.PL "..., 4096) = 3836
read(6, "erformance where n is the number"..., 4096) = 362
read(6, "#\n\npackage IO::File;\n\n=head1 NAM"..., 4096) = 3955
read(8, "####################\n## State mo"..., 4096) = 3375
getgroups32(32, [500, 16, 10])          = 3
getgroups32(32, [500, 16, 10])          = 3
read(7, "ec->abs2rel( $path, $base ) ;\n\nI"..., 4096) = 3798
getgroups32(32, [500, 16, 10])          = 3
getgroups32(32, [500, 16, 10])          = 3
read(6, "package re;\n\nour $VERSION = 0.03"..., 4096) = 3988
read(5, "}\n\n\nsub phrase  { set_or_get(shi"..., 4096) = 3851
read(6, "package integer;\n\nour $VERSION ="..., 4096) = 3266
read(6, "{\n\t    push(@created,mkpath($par"..., 4096) = 3256
read(8, "# Copyright (c) 2000-2003 Dave R"..., 4096) = 3099
read(7, "risbane\',\n  \'Australia/South\' =>"..., 4096) = 3960
read(5, "package DateTime::Infinite;\n\nuse"..., 4096) = 3373
read(5, "package Test::Common;\n\nuse s"..., 4096) = 3534
read(9, "package Class::Data::Inheritable"..., 4096) = 3650
read(8, "package Class::DBI::ColumnGroupe"..., 4096) = 3044
read(5, "package Test::Shared;\n\nuse s"..., 4096) = 328
getgroups32(32, [500, 16, 10])          = 3
alarm(0)                                = 300

seems it is accept who returns IO handler 3.

Frank Maas wrote:

>Hi Aleksandr,
>
>You say the process hangs here:
>
>  
>
>>read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
>>--- SIGWINCH (Window changed) @ 0 (0) ---
>>read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
>>--- SIGWINCH (Window changed) @ 0 (0) ---
>>read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
>>--- SIGWINCH (Window changed) @ 0 (0) ---
>>read(3,
>>    
>>
>
>then it would be nice to know to what handle 3 is attached. Can you
>look through the trace for some pointers on this. Perhaps a similar
>set of lines like
>
>  
>
>>open("/tmp/Apache-Session-e332c162d925d21c424a1a43e809e2fd.lock", 
>>O_RDWR|O_CREAT|O_TRUNC|O_LAR
>>GEFILE, 0666) = 4
>>    
>>
>
>that in this case attaches to handle 4. Please note that there might
>be a lot of attaching and closing of handle 3, we are looking for
>the last one that remains open until that read.
>
>Best regards,
>
>Frank
>
>  
>



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Frank Maas <fr...@cheiron-it.nl>.
Hi Aleksandr,

You say the process hangs here:

> read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGWINCH (Window changed) @ 0 (0) ---
> read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGWINCH (Window changed) @ 0 (0) ---
> read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGWINCH (Window changed) @ 0 (0) ---
> read(3,

then it would be nice to know to what handle 3 is attached. Can you
look through the trace for some pointers on this. Perhaps a similar
set of lines like

> open("/tmp/Apache-Session-e332c162d925d21c424a1a43e809e2fd.lock", 
> O_RDWR|O_CREAT|O_TRUNC|O_LAR
> GEFILE, 0666) = 4

that in this case attaches to handle 4. Please note that there might
be a lot of attaching and closing of handle 3, we are looking for
the last one that remains open until that read.

Best regards,

Frank

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:

>>>> I need to see that backtrace in hope to get an idea of what's going on.
>>>
>>>
>>> How to do that ?
>>> I started httpd within gdb, then send it a sigint:
>>>
>>> (gdb) run -X -f /home/ag/development/tauction/conf/httpd.conf
>>> Starting program: /usr/local/apache-perl/bin/httpd -X -f 
>>> /home/ag/development/test/conf/httpd.conf
>>> (no debugging symbols found)...(no debugging symbols found)...[New 
>>> Thread 1024 (LWP 18788)]
>>
>>
>> why do you send it any signal at all? You say that it segfaults on its 
>> own when timeout happens. Just start the program under gdb and then 
>> issue that request that triggers the segfault.
> 
> 
> No, I said apache segfaults not when timeout happens. It segfaults when 
> I stop apache process in which timeout occured.
> Eg. I start the process, then make a request which timeouts - the apache 
> works ok even after timeout
> and continue to serve requests.  But if I stop (with sigint or sighup) 
> this apache process - it stops and print "segmentation fault".
> That means that the "segmentation fault" occurs in the cleanup stage, 
> when the apache process exits.
> If during the life of this process there were no timeouts - the process 
> exits ok.
> So somehow I need to trace apache's cleanup phase - the code which is 
> executed when apache process gets sig(hup|int).

Aha! thanks for the explanation, Alex. What happens if start Apache in a 
single server mode and do the same? Does it segfault? If not that would 
explain why you can't catch it with gdb (since you run it in a single server 
mode there). In which case you'd need to configure your system to dump the 
core file and get the trace from it. The URL I've posted earlier includes the 
details on what needs to be done in order to get the core file dumped.

[...]

>> Hmm, I wonder if Apache::Request should be changed to let the user 
>> control the timeout, without the backtrace I can't tell where the 
>> problem is, but if it's due to perl, then setting it on the C level 
>> before it reads the data might be different. Since it works fine after 
>> 300 secs timeout, isn't it?
> 
> 
> Yep - it works fine after the timeout. But the perl code in which 
> timeout happens isn't executed... eg if $apr->param timeouts
> - no code after this statement isn't executed:
>   ...
>   $r->server->timeout(1);
>   $apr->param;
>   warn "this will never appear in the log if the timeout during 
> \$apr->param occured";
>   ...

So it could be related to longjmp issued when timeout happens, which messes 
things up. The worst part is that you don't reset the timeout to the original 
value. Have you tried adding a cleanup handler to do that?

my $timeout = $r->server->timeout(1);
$r->push_handlers(PerlCleanupHandler =>
     sub { shift->server->timeout($timeout);});
$apr->param;

Please check that it gets to run at all (add a warning or something).

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Hi Stas
Stas Bekman wrote:

> Aleksandr Guidrevitch wrote:
>
>>> I need to see that backtrace in hope to get an idea of what's going on.
>>
>> How to do that ?
>> I started httpd within gdb, then send it a sigint:
>>
>> (gdb) run -X -f /home/ag/development/tauction/conf/httpd.conf
>> Starting program: /usr/local/apache-perl/bin/httpd -X -f 
>> /home/ag/development/test/conf/httpd.conf
>> (no debugging symbols found)...(no debugging symbols found)...[New 
>> Thread 1024 (LWP 18788)]
>
> why do you send it any signal at all? You say that it segfaults on its 
> own when timeout happens. Just start the program under gdb and then 
> issue that request that triggers the segfault.

No, I said apache segfaults not when timeout happens. It segfaults when 
I stop apache process in which timeout occured.
Eg. I start the process, then make a request which timeouts - the apache 
works ok even after timeout
and continue to serve requests.  But if I stop (with sigint or sighup) 
this apache process - it stops and print "segmentation fault".
That means that the "segmentation fault" occurs in the cleanup stage, 
when the apache process exits.
If during the life of this process there were no timeouts - the process 
exits ok.
So somehow I need to trace apache's cleanup phase - the code which is 
executed when apache process gets sig(hup|int).


>> sub handler {
>>    ...
>>    open(F, ">/tmp/test-$$") && close(F);
>>    $apr->param;
>>    unlink "/tmp/test-$$";
>>    ...
>> }
>>
>> then another server scans each second /tmp dir for the /^test-(\d+)$/ 
>> files modified
>> more than 2 second ago, kill the appropriate process $1 and removes 
>> the appropriate file in /tmp.
>> It is ugly, I know... But at the moment I don't see any better solution
>
> Also I came to the following solution:
>
> Hmm, I wonder if Apache::Request should be changed to let the user 
> control the timeout, without the backtrace I can't tell where the 
> problem is, but if it's due to perl, then setting it on the C level 
> before it reads the data might be different. Since it works fine after 
> 300 secs timeout, isn't it?

Yep - it works fine after the timeout. But the perl code in which 
timeout happens isn't executed... eg if $apr->param timeouts
- no code after this statement isn't executed:
   ...
   $r->server->timeout(1);
   $apr->param;
   warn "this will never appear in the log if the timeout during 
\$apr->param occured";
   ...

Alex



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:

>> I need to see that backtrace in hope to get an idea of what's going on.
> 
> 
> How to do that ?
> I started httpd within gdb, then send it a sigint:
> 
> (gdb) run -X -f /home/ag/development/tauction/conf/httpd.conf
> Starting program: /usr/local/apache-perl/bin/httpd -X -f 
> /home/ag/development/test/conf/httpd.conf
> (no debugging symbols found)...(no debugging symbols found)...[New 
> Thread 1024 (LWP 18788)]

why do you send it any signal at all? You say that it segfaults on its own 
when timeout happens. Just start the program under gdb and then issue that 
request that triggers the segfault.

> Also I came to the following solution:
> sub handler {
>    ...
>    open(F, ">/tmp/test-$$") && close(F);
>    $apr->param;
>    unlink "/tmp/test-$$";
>    ...
> }
> 
> then another server scans each second /tmp dir for the /^test-(\d+)$/ 
> files modified
> more than 2 second ago, kill the appropriate process $1 and removes the 
> appropriate file in /tmp.
> It is ugly, I know... But at the moment I don't see any better solution

Hmm, I wonder if Apache::Request should be changed to let the user control the 
timeout, without the backtrace I can't tell where the problem is, but if it's 
due to perl, then setting it on the C level before it reads the data might be 
different. Since it works fine after 300 secs timeout, isn't it?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Stas Bekman wrote:

>> As I've already said - if the server times out (in the example above) 
>> at least once -
>> it still continue serving requests. But when I press ctrl-c to stop 
>> the server - it stops
>> with segmentation fault, that means segmentation fault occurs only 
>> when the server
>> get a ctrl-c (sigint). I also tested kill -1 <httpd pid> (with 
>> sighup) - httpd exit with segfault too.
>
> Yep, I tried to eval $apr->request, as well as eval the whole block 
> including the code which sets and restores the timeout
>
> Stopping server with Ctrl-C is probably not the best idea ;)

killing with sighup causes the segmentation fault too :)

>> that perl garbage collector is not executed after the timeout), since 
>> there is no way to correctly
>> handle this situation ?
>
> I just wonder how that will influence of the overall stability and 
> memory usage (since it seems
>
> I need to see that backtrace in hope to get an idea of what's going on.

How to do that ?
I started httpd within gdb, then send it a sigint:

(gdb) run -X -f /home/ag/development/tauction/conf/httpd.conf
Starting program: /usr/local/apache-perl/bin/httpd -X -f 
/home/ag/development/test/conf/httpd.conf
(no debugging symbols found)...(no debugging symbols found)...[New 
Thread 1024 (LWP 18788)]

Program received signal SIGINT, Interrupt.
[Switching to Thread 1024 (LWP 18788)]
0x402749a4 in read () from /lib/libc.so.6
(gdb) where
#0  0x402749a4 in read () from /lib/libc.so.6
#1  0x401b6ac0 in __JCR_LIST__ () from /lib/libpthread.so.0
#2  0x080a73a0 in ap_bhalfduplex ()
#3  0x080a7519 in ap_bread ()
#4  0x080b5f4b in ap_get_client_block ()
.......

If i kill it with `kill -HUP <httpd pid>` :

Program received signal SIGTERM, Terminated.
[Switching to Thread 1024 (LWP 18928)]
0x402749a4 in read () from /lib/libc.so.6
(gdb) where
#0  0x402749a4 in read () from /lib/libc.so.6
#1  0x401b6ac0 in __JCR_LIST__ () from /lib/libpthread.so.0
#2  0x080a73a0 in ap_bhalfduplex ()
#3  0x080a7519 in ap_bread ()
#4  0x080b5f4b in ap_get_client_block ()
.......

How else can I debug/backtrace it to catch this segmentation fault ?

Also I came to the following solution:
sub handler {
    ...
    open(F, ">/tmp/test-$$") && close(F);
    $apr->param;
    unlink "/tmp/test-$$";
    ...
}

then another server scans each second /tmp dir for the /^test-(\d+)$/ 
files modified
more than 2 second ago, kill the appropriate process $1 and removes the 
appropriate file in /tmp.
It is ugly, I know... But at the moment I don't see any better solution

Alex



-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:
> Stas Bekman wrote:
> 
>>>>> yep, that closes the connection after $timeout_secs and looks to me 
>>>>> like the right solution.
>>>>> However, If I try to stop apache it exits with 'Segmentation fault' 
>>>>> (in case a timeout occured),
>>>>> seems due to the fact that the perl code haven't had a chance to 
>>>>> clean up. Can I trap this timeout ?
>>>>
>>>>
>>>> I don't think you can. I think this API is not really used by 
>>>> anyone, hence no wonder if it causes a segfault. Can you post a 
>>>> backtrace?
>>>
>>>
>>> how can I do that ? Strace with $r->server->timeout(1) :
>>
>>
>> You mean how to get a corefile backtrace? It's explained here:
>> http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems
> 
> 
> I've attached to the spinning process of httpd:
[...]
> Is that of any help ?

no. Earlier you said:

------------
yep, that closes the connection after $timeout_secs and looks to me like the 
right solution.
However, If I try to stop apache it exits with 'Segmentation fault' (in case a 
timeout occured),
seems due to the fact that the perl code haven't had a chance to clean up. Can 
I trap this timeout ?
-------------

so I've asked you to show the backtrace from that 'Segmentation fault'.

>>> Yep, I tried to eval $apr->request, as well as eval the whole block 
>>> including the code which sets and restores the timeout
>>>
>>> 1. sub handler ($$) {
>>>    my $orig_timeout = $r->server->timeout(1);
>>>    eval { $apr->param };
>>>    $r->server->timeout($orig_timeout_secs);
>>>    warn "-------", $@, $!;
>>> }
>>
>>
>> (1) looks good. Of course you need to send 'content-type', return OK 
>> and such, so I'm not sure what do you mean when you say "do not work". 
>> Does it segfault?
> 
> 
> nope, sorry for misdirecting you :)
> If the server times out during $apr->param - it never gets to the warn 
> "------",
> that means it never returns from the eval block ! It doesn't matter what 
> is after "eval { $apr->param }; "
> - it will never be executed. However httpd will continue to serve the 
> consequent requests.
> 
> As I've already said - if the server times out (in the example above) at 
> least once -
> it still continue serving requests. But when I press ctrl-c to stop the 
> server - it stops
> with segmentation fault, that means segmentation fault occurs only when 
> the server
> get a ctrl-c (sigint). I also tested kill -1 <httpd pid> (with sighup) - 
> httpd exit with segfault too.

Stopping server with Ctrl-C is probably not the best idea ;)

> I just wonder how that will influence of the overall stability and 
> memory usage (since it seems
> that perl garbage collector is not executed after the timeout), since 
> there is no way to correctly
> handle this situation ?

I need to see that backtrace in hope to get an idea of what's going on.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Stas Bekman wrote:

>>>> yep, that closes the connection after $timeout_secs and looks to me 
>>>> like the right solution.
>>>> However, If I try to stop apache it exits with 'Segmentation fault' 
>>>> (in case a timeout occured),
>>>> seems due to the fact that the perl code haven't had a chance to 
>>>> clean up. Can I trap this timeout ?
>>>
>>> I don't think you can. I think this API is not really used by 
>>> anyone, hence no wonder if it causes a segfault. Can you post a 
>>> backtrace?
>>
>> how can I do that ? Strace with $r->server->timeout(1) :
>
> You mean how to get a corefile backtrace? It's explained here:
> http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems

I've attached to the spinning process of httpd:
(gdb) where
#0  0x402749a4 in read () from /lib/libc.so.6
#1  0x401b6ac0 in __JCR_LIST__ () from /lib/libpthread.so.0
#2  0x080a73a0 in ap_bhalfduplex ()
#3  0x080a7519 in ap_bread ()
#4  0x080b5f4b in ap_get_client_block ()
#5  0x403689be in fill_buffer () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#6  0x40368ad8 in get_line () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#7  0x40368b18 in find_boundary () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#8  0x40368c46 in multipart_buffer_headers () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#9  0x403680f6 in ApacheRequest_parse_multipart () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#10 0x40367c3f in ApacheRequest___parse () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#11 0x403639d8 in XS_Apache__Request_param () from 
/usr/local/lib/perl5/site_perl/5.8.0/i386-linux/auto/Apache/Request/Request.so
#12 0x400fd912 in Perl_pp_entersub () from /usr/lib/libperl.so.5.8
#13 0x400f6129 in Perl_runops_standard () from /usr/lib/libperl.so.5.8
#14 0x4009e1f9 in S_call_body () from /usr/lib/libperl.so.5.8
#15 0x4009df83 in Perl_call_sv () from /usr/lib/libperl.so.5.8
#16 0x4009dac6 in Perl_call_method () from /usr/lib/libperl.so.5.8
#17 0x08068369 in perl_call_handler ()
#18 0x08067c26 in perl_run_stacked_handlers ()
#19 0x08065a44 in perl_handler ()
#20 0x080a8918 in ap_invoke_handler ()
#21 0x080b8b05 in ap_some_auth_required ()
#22 0x080b8cba in ap_process_request ()
#23 0x080b1f8e in ap_child_terminate ()
#24 0x080b216f in ap_child_terminate ()
#25 0x080b21e8 in ap_child_terminate ()
#26 0x080b2bcb in ap_child_terminate ()
#27 0x080b2ecf in main ()
#28 0x401cf4d2 in __libc_start_main () from /lib/libc.so.6
(gdb) source ~/Install/mod_perl-1.29/.gdbinit
(gdb) curinfo
No symbol "PL_curcop" in current context.

Is that of any help ?

>> Yep, I tried to eval $apr->request, as well as eval the whole block 
>> including the code which sets and restores the timeout
>>
>> 1. sub handler ($$) {
>>    my $orig_timeout = $r->server->timeout(1);
>>    eval { $apr->param };
>>    $r->server->timeout($orig_timeout_secs);
>>    warn "-------", $@, $!;
>> }
>
> (1) looks good. Of course you need to send 'content-type', return OK 
> and such, so I'm not sure what do you mean when you say "do not work". 
> Does it segfault?

nope, sorry for misdirecting you :)
If the server times out during $apr->param - it never gets to the warn 
"------",
that means it never returns from the eval block ! It doesn't matter what 
is after "eval { $apr->param }; "
- it will never be executed. However httpd will continue to serve the 
consequent requests.

As I've already said - if the server times out (in the example above) at 
least once -
it still continue serving requests. But when I press ctrl-c to stop the 
server - it stops
with segmentation fault, that means segmentation fault occurs only when 
the server
get a ctrl-c (sigint). I also tested kill -1 <httpd pid> (with sighup) - 
httpd exit with segfault too.

I just wonder how that will influence of the overall stability and 
memory usage (since it seems
that perl garbage collector is not executed after the timeout), since 
there is no way to correctly
handle this situation ?

Alex


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:
> Hi Stas
> 
> Stas Bekman wrote:
> 
>>> yep, that closes the connection after $timeout_secs and looks to me 
>>> like the right solution.
>>> However, If I try to stop apache it exits with 'Segmentation fault' 
>>> (in case a timeout occured),
>>> seems due to the fact that the perl code haven't had a chance to 
>>> clean up. Can I trap this timeout ?
>>
>>
>>
>> I don't think you can. I think this API is not really used by anyone, 
>> hence no wonder if it causes a segfault. Can you post a backtrace?
> 
> 
> how can I do that ? Strace with $r->server->timeout(1) :

You mean how to get a corefile backtrace? It's explained here:
http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems

>> Did you set the perl trap as well? You shouldn't if you set Apache's 
>> timeout already. Just wrap $apr->param in eval {}; in the above 
>> snippet to trap the failure.
> 
> 
> Yep, I tried to eval $apr->request, as well as eval the whole block 
> including the code which sets and restores the timeout
> 
> 1. sub handler ($$) {
>    my $orig_timeout = $r->server->timeout(1);
>    eval { $apr->param };
>    $r->server->timeout($orig_timeout_secs);
>    warn "-------", $@, $!;
> }

> 2. sub handler ($$) {
>    eval {
>        my $orig_timeout = $r->server->timeout(1);
>        $apr->param;
>        $r->server->timeout($orig_timeout_secs);
>    }
>    warn "-------", $@, $!;
> }
> 
> both ways do not work :(((


(1) looks good. Of course you need to send 'content-type', return OK and such, 
so I'm not sure what do you mean when you say "do not work". Does it segfault?

>> BTW, what happens if you set the Apache alarm to 0, does it still set 
>> it? Can you try:
>>
>>   my $orig_timeout = $r->server->timeout(0);
>>   $apr->param;
>>
>> and then strace to see whether it sets it at all. I guess we can look 
>> at the source code, but strace is more fun ;)
> 
> 
> all the alarms I got via strace:
[...]
> alarm(300)                              = 0
> read(3, "------------5dcexM6YlOS1TIaELqOT"..., 4096) = 664
> alarm(0)                                = 300
> alarm(300)                              = 0
> read(3,  <unfinished ...>

so if you set it to 0, it uses the default 300 value.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Hi Stas

Stas Bekman wrote:

>> yep, that closes the connection after $timeout_secs and looks to me 
>> like the right solution.
>> However, If I try to stop apache it exits with 'Segmentation fault' 
>> (in case a timeout occured),
>> seems due to the fact that the perl code haven't had a chance to 
>> clean up. Can I trap this timeout ?
>
>
> I don't think you can. I think this API is not really used by anyone, 
> hence no wonder if it causes a segfault. Can you post a backtrace?

how can I do that ? Strace with $r->server->timeout(1) :

brk(0x8a99000)                          = 0x8a99000
alarm(1)                                = 0
read(3, "------------5dcexM6YlOS1TIaELqOT"..., 4096) = 664
alarm(0)                                = 1
alarm(1)                                = 0
read(3, 0x8293b94, 4096)                = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
time(NULL)                              = 1070572385
write(17, "127.0.0.1 - - [04/Dec/2003:23:13"..., 84) = 84
close(3)                                = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], NULL, 8) = 0
rt_sigaction(SIGURG, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 
0x401e06f8}, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, 8) = 0
rt_sigaction(SIGALRM, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 
0x401e06f8}, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, 8) = 0
rt_sigaction(SIGUSR1, {0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 
0x401e06f8}, {SIG_IGN}, 8) = 0
alarm(0)                                = 0
rt_sigaction(SIGALRM, {0x401ab070, [], SA_RESTORER, 0x401e06f8}, 
{0x401ab070, [], SA_RESTORER|SA_INTERRUPT, 0x401e06f8}, 8) = 0
accept(16,

> Did you set the perl trap as well? You shouldn't if you set Apache's 
> timeout already. Just wrap $apr->param in eval {}; in the above 
> snippet to trap the failure.

Yep, I tried to eval $apr->request, as well as eval the whole block 
including the code which sets and restores the timeout

1. sub handler ($$) {
    my $orig_timeout = $r->server->timeout(1);
    eval { $apr->param };
    $r->server->timeout($orig_timeout_secs);
    warn "-------", $@, $!;
}

2. sub handler ($$) {
    eval {
        my $orig_timeout = $r->server->timeout(1);
        $apr->param;
        $r->server->timeout($orig_timeout_secs);
    }
    warn "-------", $@, $!;
}

both ways do not work :(((

> BTW, what happens if you set the Apache alarm to 0, does it still set 
> it? Can you try:
>
>   my $orig_timeout = $r->server->timeout(0);
>   $apr->param;
>
> and then strace to see whether it sets it at all. I guess we can look 
> at the source code, but strace is more fun ;)

all the alarms I got via strace:
alarm(0)                                = 0
alarm(300)                              = 0
alarm(300)                              = 300
alarm(0)                                = 300
alarm(300)                              = 0
alarm(0)                                = 300
alarm(300)                              = 0

tail strace :

ead(5, "", 4096)                       = 0
close(5)                                = 0
munmap(0x40331000, 4096)                = 0
brk(0x8a93000)                          = 0x8a93000
brk(0x8a94000)                          = 0x8a94000
brk(0x8a95000)                          = 0x8a95000
brk(0x8a96000)                          = 0x8a96000
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0x40330000, 4096)                = 0
brk(0x8a99000)                          = 0x8a99000
alarm(300)                              = 0
read(3, "------------5dcexM6YlOS1TIaELqOT"..., 4096) = 664
alarm(0)                                = 300
alarm(300)                              = 0
read(3,  <unfinished ...>

(I pressed ctrl-c here :)

Sincerely,
Alex


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:
> Hello, Stas
> Stas Bekman wrote:
> 
>> alarm(300) is an Apache alarm. Can you see the perl's alarm calls 
>> earlier in the trace? since you tried alarm 1, grep for alarm(1).
> 
> 
> [ag@aguidrevitch tauction]$ grep -P 'alarm' <strace.log
> alarm(0)                                = 0
> alarm(300)                              = 0
> alarm(300)                              = 300
> alarm(0)                                = 300
> alarm(1)                                = 0
> alarm(300)                              = 0
> alarm(0)                                = 300
> alarm(300)                              = 0
> 
> seems it is here

Thanks. So you can see that Apache overrides perl's alarm:

 > alarm(1)                                = 0
 > alarm(300)                              = 0

>> I think what happens is that perl sets the alarm, but then Apache 
>> resets it again to its own value and its own sighandler. Even though 
>> it may restore the perl sighandle at the end it's happening too late.
>>
>> So i'd try:
>>
>> 1)
>>
>> You could try to lower Apache's IO timeout for this call. I can't see 
>> it documented (defined in Server.xs) but you can read/write server 
>> timeout values:
>>
>>   my $timeout_secs = 1;
>>   my $orig_timeout = $r->server->timeout($timeout_secs);
>>   $apr->param; # no perl alarm is now needed
>>   $r->server->timeout($orig_timeout_secs);
> 
> 
> yep, that closes the connection after $timeout_secs and looks to me like 
> the right solution.
> However, If I try to stop apache it exits with 'Segmentation fault' (in 
> case a timeout occured),
> seems due to the fact that the perl code haven't had a chance to clean 
> up. Can I trap this timeout ?

I don't think you can. I think this API is not really used by anyone, hence no 
wonder if it causes a segfault. Can you post a backtrace?

Did you set the perl trap as well? You shouldn't if you set Apache's timeout 
already. Just wrap $apr->param in eval {}; in the above snippet to trap the 
failure.

BTW, what happens if you set the Apache alarm to 0, does it still set it? Can 
you try:

   my $orig_timeout = $r->server->timeout(0);
   $apr->param;

and then strace to see whether it sets it at all. I guess we can look at the 
source code, but strace is more fun ;)

>> 2)  I'm not sure this will work, since read will probably set the 
>> alarm after kill_timeout, so it won't accomplish that affect.
>>
>>   $r->kill_timeout;
>>   ... alarm eval here with $apr->param call ...
>>   $r->reset_timeout;
>> http://perl.apache.org/docs/1.0/api/Apache.html#_r_E_gt_reset_timeout
> 
> 
> that doesn't work

Ok, thanks for verifying.

>> 3) Try Sys::Signal to set the perl alarm. I don't think though it'll 
>> give you the solution, since it was written to have the C level 
>> sighandlers restored after perl's sighandler was called. And recent 
>> Apache versions are supposed to work well with plain perl sighandlers.
> 
> 
> it doesn't compile for me :((

Yes, I remember I had probs with recent perls too, but since it's not really 
needed and we know exactly what the problem is, let's just leave it alone.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Hello, Stas
Stas Bekman wrote:

> alarm(300) is an Apache alarm. Can you see the perl's alarm calls 
> earlier in the trace? since you tried alarm 1, grep for alarm(1).

[ag@aguidrevitch tauction]$ grep -P 'alarm' <strace.log
alarm(0)                                = 0
alarm(300)                              = 0
alarm(300)                              = 300
alarm(0)                                = 300
alarm(1)                                = 0
alarm(300)                              = 0
alarm(0)                                = 300
alarm(300)                              = 0

seems it is here

> I think what happens is that perl sets the alarm, but then Apache 
> resets it again to its own value and its own sighandler. Even though 
> it may restore the perl sighandle at the end it's happening too late.
>
> So i'd try:
>
> 1)
>
> You could try to lower Apache's IO timeout for this call. I can't see 
> it documented (defined in Server.xs) but you can read/write server 
> timeout values:
>
>   my $timeout_secs = 1;
>   my $orig_timeout = $r->server->timeout($timeout_secs);
>   $apr->param; # no perl alarm is now needed
>   $r->server->timeout($orig_timeout_secs);

yep, that closes the connection after $timeout_secs and looks to me like 
the right solution.
However, If I try to stop apache it exits with 'Segmentation fault' (in 
case a timeout occured),
seems due to the fact that the perl code haven't had a chance to clean 
up. Can I trap this timeout ?

>
> 2)  I'm not sure this will work, since read will probably set the 
> alarm after kill_timeout, so it won't accomplish that affect.
>
>   $r->kill_timeout;
>   ... alarm eval here with $apr->param call ...
>   $r->reset_timeout;
> http://perl.apache.org/docs/1.0/api/Apache.html#_r_E_gt_reset_timeout

that doesn't work

> 3) Try Sys::Signal to set the perl alarm. I don't think though it'll 
> give you the solution, since it was written to have the C level 
> sighandlers restored after perl's sighandler was called. And recent 
> Apache versions are supposed to work well with plain perl sighandlers.

it doesn't compile for me :((

Thanks


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Charles C. Fu (傅建文) wrote:
> In <3F...@stason.org> on 03 Dec 2003,
>    Stas Bekman <st...@stason.org> wrote:
> 
>>I'm not sure what SIGWINCH is, was it a concole switching event?
> 
> 
> It's normally a window resize event.  Maybe Aleksandr was resizing the
> terminal emulator window in which he started Apache in order to try to
> see more of the strace output??

Thanks, Charles, I can reproduce this with a simple:

% strace perl -le 'sleep 10'

and resizing the window.

So it's unrelated to the problem in hand.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by "Charles C. Fu" <pe...@web-i18n.net>.
In <3F...@stason.org> on 03 Dec 2003,
   Stas Bekman <st...@stason.org> wrote:
> I'm not sure what SIGWINCH is, was it a concole switching event?

It's normally a window resize event.  Maybe Aleksandr was resizing the
terminal emulator window in which he started Apache in order to try to
see more of the strace output??

-ccwf
-- 
Charles C. Fu                           ,--
Founder                ___  __ __. . ,-/--
Web i18n, LLC              (_,(_,|/|/ /
www.web-i18n.net                 ----'

-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:
> Stas Bekman wrote:
> 
>> I suppose that since $apr->param is an XSUB perl decides that it's 
>> unsafe to interrupt it. Or may be it's an OS issue, so perl doesn't 
>> even get a chance to intervene.
>>
>> Have you tried strace(1)ing httpd and seeing where does it hang? Of 
>> course start the server with -X so you have only one pid to track.
> 
> 
> The output of strace is too long, here are some of the last lines:
[...]

> alarm(300)                              = 0
> read(3, "------------SFQ0oV5N2ysZosOirvfy"..., 4096) = 664
> alarm(0)                                = 300
> alarm(300)                              = 0
> read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGWINCH (Window changed) @ 0 (0) ---
> read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGWINCH (Window changed) @ 0 (0) ---
> read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGWINCH (Window changed) @ 0 (0) ---
> read(3,
> 
> it hanged here. Seems after 300 seconds, it continued and died:
> 
> 
> 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
> --- SIGALRM (Alarm clock) @ 0 (0) ---
> +++ killed by SIGALRM +++
> 
> Is it related to the reading request from the client ?

I'm not sure what SIGWINCH is, was it a concole switching event?

> Will front-end server solve the problem ?

alarm(300) is an Apache alarm. Can you see the perl's alarm calls earlier in 
the trace? since you tried alarm 1, grep for alarm(1).

I think what happens is that perl sets the alarm, but then Apache resets it 
again to its own value and its own sighandler. Even though it may restore the 
perl sighandle at the end it's happening too late.

So i'd try:

1)

You could try to lower Apache's IO timeout for this call. I can't see it 
documented (defined in Server.xs) but you can read/write server timeout values:

   my $timeout_secs = 1;
   my $orig_timeout = $r->server->timeout($timeout_secs);
   $apr->param; # no perl alarm is now needed
   $r->server->timeout($orig_timeout_secs);

2)  I'm not sure this will work, since read will probably set the alarm after 
kill_timeout, so it won't accomplish that affect.

   $r->kill_timeout;
   ... alarm eval here with $apr->param call ...
   $r->reset_timeout;
http://perl.apache.org/docs/1.0/api/Apache.html#_r_E_gt_reset_timeout

3) Try Sys::Signal to set the perl alarm. I don't think though it'll give you 
the solution, since it was written to have the C level sighandlers restored 
after perl's sighandler was called. And recent Apache versions are supposed to 
work well with plain perl sighandlers.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Stas Bekman wrote:

> I suppose that since $apr->param is an XSUB perl decides that it's 
> unsafe to interrupt it. Or may be it's an OS issue, so perl doesn't 
> even get a chance to intervene.
>
> Have you tried strace(1)ing httpd and seeing where does it hang? Of 
> course start the server with -X so you have only one pid to track.

The output of strace is too long, here are some of the last lines:

read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0x40330000, 4096)                = 0
brk(0x8ab4000)                          = 0x8ab4000
open("/tmp/Apache-Session-e332c162d925d21c424a1a43e809e2fd.lock", 
O_RDWR|O_CREAT|O_TRUNC|O_LAR
GEFILE, 0666) = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
flock(4, LOCK_SH)                       = 0
stat64("/home/ag/development/test/src/sessions/e332c162d925d21c424a1a43e809e2fd", 
{st_mode                                                =S_IFREG|0644, 
st_size=81, ...}) = 0
open("/home/ag/development/test/src/sessions/e332c162d925d21c424a1a43e809e2fd", 
O_RDWR|O_C                                                
REAT|O_LARGEFILE, 0666) = 5
fcntl64(5, F_GETFL)                     = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat64(5, {st_mode=S_IFREG|0644, st_size=81, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0x40330000
_llseek(5, 0, [0], SEEK_CUR)            = 0
fstat64(5, {st_mode=S_IFREG|0644, st_size=81, ...}) = 0
fcntl64(5, F_SETFD, FD_CLOEXEC)         = 0
read(5, "\5\6\3\0\0\0\3\n e332c162d925d21c424a1a4"..., 4096) = 81
read(5, "", 4096)                       = 0
read(5, "", 4096)                       = 0
stat64("/usr/lib/perl5/i386-linux/auto/Storable/thaw.al", 
{st_mode=S_IFREG|0444, 
st_size=662,                                                 ...}) = 0
getgroups32(32, [500, 16, 10])          = 3
open("/usr/lib/perl5/i386-linux/auto/Storable/thaw.al", 
O_RDONLY|O_LARGEFILE) = 6
brk(0x8ab5000)                          = 0x8ab5000
fstat64(6, {st_mode=S_IFREG|0444, st_size=662, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 
0) = 0x40331000
read(6, "# NOTE: Derived from blib/lib/St"..., 4096) = 662
brk(0x8ab6000)                          = 0x8ab6000
close(6)                                = 0
munmap(0x40331000, 4096)                = 0
brk(0x8ab9000)                          = 0x8ab9000
alarm(300)                              = 0
read(3, "------------SFQ0oV5N2ysZosOirvfy"..., 4096) = 664
alarm(0)                                = 300
alarm(300)                              = 0
read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
--- SIGWINCH (Window changed) @ 0 (0) ---
read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
--- SIGWINCH (Window changed) @ 0 (0) ---
read(3, 0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
--- SIGWINCH (Window changed) @ 0 (0) ---
read(3,

it hanged here. Seems after 300 seconds, it continued and died:


0x8293b7c, 4096)                = ? ERESTARTSYS (To be restarted)
--- SIGALRM (Alarm clock) @ 0 (0) ---
+++ killed by SIGALRM +++

Is it related to the reading request from the client ?
Will front-end server solve the problem ?

Sincerely,
Alex




-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:
> Hi, Stas
> 
>    # working around buggy opera multipart/form-data
>    eval {
>        local $SIG{ALRM} =
>            sub { die "Sorry timed out. Please try again\n" };
>        alarm 1;
>        $apr->param;
>        alarm 0;
>    };
>    warn "works ok\n";
> 
> It doesn't work :( Any other suggestions ?

I suppose that SIGALRM works properly with perl functions which may block, for 
example this one liner blocks (if you don't touch the keyboard):

% perl -le '<STDIN>'

and this does the right thing:

% perl -le 'eval { $SIG{ALRM} = sub { die "skipping read" }; alarm 2; \
             <STDIN>; alarm 0;}; warn "failed: $@" if $@'
failed: skipping read at -e line 1.

Looks like even an external blocking command can be alarmed:

# blocking forever
% perl -le ' qx[tail -F /tmp/whatever]'
tail: /tmp/whatever: No such file or directory

# unblocked in 2 secs
% perl -le 'eval { $SIG{ALRM} = sub { die "skipping read" }; alarm 2; \
             qx[tail -F /tmp/whatever]; alarm 0;}; warn "failed: $@" if $@'
tail: /tmp/whatever: No such file or directory
failed: skipping read at -e line 1.

I suppose that since $apr->param is an XSUB perl decides that it's unsafe to 
interrupt it. Or may be it's an OS issue, so perl doesn't even get a chance to 
intervene.

Have you tried strace(1)ing httpd and seeing where does it hang? Of course 
start the server with -X so you have only one pid to track.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Aleksandr Guidrevitch <pi...@tut.by>.
Hi, Stas

    # working around buggy opera multipart/form-data
    eval {
        local $SIG{ALRM} =
            sub { die "Sorry timed out. Please try again\n" };
        alarm 1;
        $apr->param;
        alarm 0;
    };
    warn "works ok\n";

It doesn't work :( Any other suggestions ?
Alex

Stas Bekman wrotes:

> using SIGALRM is documented here:
> http://perl.apache.org/docs/1.0/guide/debug.html#Handling_Server_Timeout_Cases_and_Working_with__SIG_ALRM_ 
>




-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html


Re: help, $apr->param hangs

Posted by Stas Bekman <st...@stason.org>.
Aleksandr Guidrevitch wrote:
[...]
> It doesn't matter how to fix Opera, but how can I work this situation 
> around ?
> Set timeout via signals ? Or there is another well-known solution ?

using SIGALRM is documented here:
http://perl.apache.org/docs/1.0/guide/debug.html#Handling_Server_Timeout_Cases_and_Working_with__SIG_ALRM_
Though it should be mentioned that starting from 5.8.0 perl uses "safe" 
signals delivery approach - i.e. it will deliver the signal only between the 
OPs and never during the OP, so if the function blocks forever inside an OP 
it's quite possible that the signal will never be delivered. But according to:
http://www.perldoc.com/perl5.8.0/pod/perldelta.html#Safe-Signals

   "breaking out from potentially blocking operations should still work, though."

It probably means that SIGALRM is exempted from this change.
Please give it a try and report back your findings.
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html