Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Dev

[Fwd: [rt.cpan.org #33303] Bug in Apache::SizeLimit]

 

 

ModPerl dev RSS feed   Index | Next | Previous | View Threaded


geoff at modperlcookbook

Feb 16, 2008, 11:15 AM

Post #1 of 4 (1401 views)
Permalink
[Fwd: [rt.cpan.org #33303] Bug in Apache::SizeLimit]

-------- Original Message --------
Subject: [rt.cpan.org #33303] Bug in Apache::SizeLimit
Date: Sat, 16 Feb 2008 11:11:50 -0500
From: jgoodridge [at] alum via RT <bug-mod_perl [at] rt>
Reply-To: bug-mod_perl [at] rt
To: undisclosed-recipients:;
References: <RT-Ticket-33303 [at] rt>
<5d395bd50802160810m22af26d7x7a6420527c593557 [at] mail>


Sat Feb 16 11:11:48 2008: Request 33303 was acted upon.
Transaction: Ticket created by jgoodridge [at] alum
Queue: mod_perl
Subject: Bug in Apache::SizeLimit
Broken in: (no value)
Severity: (no value)
Owner: Nobody
Requestors: jgoodridge [at] alum
Status: new
Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=33303 >


I have found a bug with Apache::SizeLimit (Note: I am not referring to
Apache2::SizeLimit -- although it may have the same problem).

PLATFORM BACKGROUND:
Mod_perl 1.29
Redhat EL5 (kernel 2.6.18)
Apache::SizeLimit version: $VERSION = '0.91-dev';
Perl version: 5.8.8

PROBLEM:
If I turn off USE_SMAPS (i.e. set Apache::SizeLimit::USE_SMAPS=0), I get an
error, specifically:

Can't call method "_linux_size_check" on an undefined value at
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Apache/SizeLimit.pm
line 216.

SOLUTION:
A diff with my fix is shown below:

************************

@@ -161,7 +163,10 @@
}

sub _check_size {
- my ( $size, $share ) = _platform_check_size();
+ my $class = shift;
+
+ my ( $size, $share ) = $class->_platform_check_size();

return ( $size, $share, $size - $share );
}

*************************
ADDITIONAL INFORMATION/QUESTION:

I ran into the problem above because I couldn't get smaps to work. I had
permission problems accessing the /proc/<pid>/smaps file. It seems that
this file (and all others in the /proc/<pid> directory) is owned by root.
While /proc/<pid>/statm is viewable by everyone, /proc/<pid>/smaps is
viewable only by root. I don't know why. The process itself is owned by
'web' -- the user that I have set to own apache child processes. Perhaps
the reason for root ownership is that the Apache parent process is owned by
root and the child processes are only setuid to 'web'. So, when the
proc/<pid>/ files are made, the child processes are still owned by root.
But that wouldn't account for why smaps in particular is readable only by
root. Do you know of a way around this? Or if some kernel change in linux
fixes this?

Thanks,
Jeremy


fred at taperfriendlymusic

Feb 16, 2008, 2:07 PM

Post #2 of 4 (1309 views)
Permalink
Re: [Fwd: [rt.cpan.org #33303] Bug in Apache::SizeLimit] [In reply to]

> Sat Feb 16 11:11:48 2008: Request 33303 was acted upon.
> Transaction: Ticket created by jgoodridge [at] alum
> PROBLEM:
> If I turn off USE_SMAPS (i.e. set Apache::SizeLimit::USE_SMAPS=0), I get
> an
> error, specifically:

I just tested this out on my Centos 5.0 platform and it looks like
Apache::SizeLimit::USE_SMAPS is undefined for t/response/basic.pm. The
test passed with and without the patch shown below.

I double checked it by explicitly setting $Apache::SizeLimit::USE_SMAPS=0
in t/response/basic.pm, same test results, and tested with
$Apache::SizeLimit::USE_SMAPS=1, same result.

However, if I set $Apache::SizeLimit::Core::USE_SMAPS=0 in basic.pm, I can
reproduce this bug. $USE_SMAPS, $VERSION, and $REQUEST_COUNT were not
being exported by Apache::SizeLimit::Core.

> Can't call method "_linux_size_check" on an undefined value at

Here is my suggested set of patches to fix these issues, with an
additional test that demonstrated the failure, and success with the code
updates.

Index: t/response/TestApache/basic.pm
===================================================================
--- t/response/TestApache/basic.pm (revision 628377)
+++ t/response/TestApache/basic.pm (working copy)
@@ -15,7 +15,7 @@
sub handler {
my $r = shift;

- plan $r, tests => 12;
+ plan $r, tests => 13;

ok( ! Apache::SizeLimit->_limits_are_exceeded(),
'check that _limits_are_exceeded() returns false without any
limits set' );
@@ -24,6 +24,16 @@
my ( $size, $shared ) = Apache::SizeLimit->_check_size();
cmp_ok( $size, '>', 0, 'proc size is reported > 0' );

+ {
+ # test with USE_SMAPS=0
+ my $smaps = $Apache::SizeLimit::USE_SMAPS;
+ $Apache::SizeLimit::USE_SMAPS = 0;
+ my ( $size, $shared ) = Apache::SizeLimit->_check_size();
+ cmp_ok( $size, '>', 0, 'proc size is reported > 0' );
+ $Apache::SizeLimit::USE_SMAPS = $smaps;
+ }
+
+
SKIP:
{
skip 'I have no idea what getppid() on Win32 might return', 1
Index: lib/Apache/SizeLimit.pm
===================================================================
--- lib/Apache/SizeLimit.pm (revision 628377)
+++ lib/Apache/SizeLimit.pm (working copy)
@@ -32,6 +32,9 @@
$MIN_SHARE_SIZE
$CHECK_EVERY_N_REQUESTS
$START_TIME
+ $USE_SMAPS
+ $VERSION
+ $REQUEST_COUNT
);
use vars qw(@ISA);
@ISA = qw(Apache::SizeLimit::Core);
Index: lib/Apache/SizeLimit/Core.pm
===================================================================
--- lib/Apache/SizeLimit/Core.pm (revision 628377)
+++ lib/Apache/SizeLimit/Core.pm (working copy)
@@ -38,6 +38,9 @@
@ISA = qw(Exporter);

@EXPORT_OK = qw(
+ $VERSION
+ $REQUEST_COUNT
+ $USE_SMAPS
$MAX_PROCESS_SIZE
$MAX_UNSHARED_SIZE
$MIN_SHARE_SIZE
@@ -111,8 +114,10 @@
}

sub _check_size {
- my ($size, $share) = _platform_check_size();
+ my $class = shift;

+ my ($size, $share) = $class->_platform_check_size();
+
return ($size, $share, $size - $share);
}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe [at] perl
For additional commands, e-mail: dev-help [at] perl


fred at taperfriendlymusic

Feb 21, 2008, 12:28 PM

Post #3 of 4 (1282 views)
Permalink
Re: [Fwd: [rt.cpan.org #33303] Bug in Apache::SizeLimit] [In reply to]

>> Sat Feb 16 11:11:48 2008: Request 33303 was acted upon.
>> Transaction: Ticket created by jgoodridge [at] alum
>> PROBLEM:
>> If I turn off USE_SMAPS (i.e. set Apache::SizeLimit::USE_SMAPS=0), I get
>> an
>> error, specifically:
> Here is my suggested set of patches to fix these issues, with an
> additional test that demonstrated the failure, and success with the code
> updates.

Any thoughts on this solution? I would need to update the mp2 components
also, but if this approach looks reasonable I can commit these changes.



> Index: t/response/TestApache/basic.pm
> ===================================================================
> --- t/response/TestApache/basic.pm (revision 628377)
> +++ t/response/TestApache/basic.pm (working copy)
> @@ -15,7 +15,7 @@
> sub handler {
> my $r = shift;
>
> - plan $r, tests => 12;
> + plan $r, tests => 13;
>
> ok( ! Apache::SizeLimit->_limits_are_exceeded(),
> 'check that _limits_are_exceeded() returns false without any
> limits set' );
> @@ -24,6 +24,16 @@
> my ( $size, $shared ) = Apache::SizeLimit->_check_size();
> cmp_ok( $size, '>', 0, 'proc size is reported > 0' );
>
> + {
> + # test with USE_SMAPS=0
> + my $smaps = $Apache::SizeLimit::USE_SMAPS;
> + $Apache::SizeLimit::USE_SMAPS = 0;
> + my ( $size, $shared ) = Apache::SizeLimit->_check_size();
> + cmp_ok( $size, '>', 0, 'proc size is reported > 0' );
> + $Apache::SizeLimit::USE_SMAPS = $smaps;
> + }
> +
> +
> SKIP:
> {
> skip 'I have no idea what getppid() on Win32 might return', 1
> Index: lib/Apache/SizeLimit.pm
> ===================================================================
> --- lib/Apache/SizeLimit.pm (revision 628377)
> +++ lib/Apache/SizeLimit.pm (working copy)
> @@ -32,6 +32,9 @@
> $MIN_SHARE_SIZE
> $CHECK_EVERY_N_REQUESTS
> $START_TIME
> + $USE_SMAPS
> + $VERSION
> + $REQUEST_COUNT
> );
> use vars qw(@ISA);
> @ISA = qw(Apache::SizeLimit::Core);
> Index: lib/Apache/SizeLimit/Core.pm
> ===================================================================
> --- lib/Apache/SizeLimit/Core.pm (revision 628377)
> +++ lib/Apache/SizeLimit/Core.pm (working copy)
> @@ -38,6 +38,9 @@
> @ISA = qw(Exporter);
>
> @EXPORT_OK = qw(
> + $VERSION
> + $REQUEST_COUNT
> + $USE_SMAPS
> $MAX_PROCESS_SIZE
> $MAX_UNSHARED_SIZE
> $MIN_SHARE_SIZE
> @@ -111,8 +114,10 @@
> }
>
> sub _check_size {
> - my ($size, $share) = _platform_check_size();
> + my $class = shift;
>
> + my ($size, $share) = $class->_platform_check_size();
> +
> return ($size, $share, $size - $share);
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe [at] perl
> For additional commands, e-mail: dev-help [at] perl
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe [at] perl
For additional commands, e-mail: dev-help [at] perl


geoff at modperlcookbook

Feb 21, 2008, 12:34 PM

Post #4 of 4 (1291 views)
Permalink
Re: [Fwd: [rt.cpan.org #33303] Bug in Apache::SizeLimit] [In reply to]

Fred Moyer wrote:
>>> Sat Feb 16 11:11:48 2008: Request 33303 was acted upon.
>>> Transaction: Ticket created by jgoodridge [at] alum
>>> PROBLEM:
>>> If I turn off USE_SMAPS (i.e. set Apache::SizeLimit::USE_SMAPS=0), I get
>>> an
>>> error, specifically:
>> Here is my suggested set of patches to fix these issues, with an
>> additional test that demonstrated the failure, and success with the code
>> updates.
>
> Any thoughts on this solution? I would need to update the mp2 components
> also, but if this approach looks reasonable I can commit these changes.

seems reasonable to me :)

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe [at] perl
For additional commands, e-mail: dev-help [at] perl

ModPerl dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.