Installation

Apache2 Hangs When Loading Problem

Apache2 Hangs When Loading Problem

by Geoff Goehle -
Number of replies: 19
Hi, I'm trying to install webwork and have a problem I can't seem to track down.

I'm using the latest version of Webwork with server version:

Server Version: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.8o PHP/5.2.13-pl0-gentoo mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.1

My issue is that when I try to load a problem in Webwork Apache seems to hang. If I monitor the server I see that the cpu usage by apache goes to 100% and eventually the connection times out. The Apache error log says that there may be an infinite loop in the problem script, but that seems unlikely because I'm using the Demo set. I can't find any other useful error log info.

I managed to get to the point whee can edit the problems and found that if I removed the "ANS" portion of the script then the problem can be displayed, including equations. So the problem is not with the equation display mode, but seems to be with Perl somehow.

I got in touch with a Webwork admin at another school and they said they had similar problems, which they fixed by installing the Ubuntu package versions of the requisite Perl modules. Our server runs Gentoo, however, so this solution won't work.

I was wondering if anyone has heard of this and knows what needs to be done to fix it.



In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Michael Gage -
H Geoff,

We have had a similar report -- from U. of New Hampshire. I haven't yet found the cause. The fact that it can be fixed by reinstalling perl suggests that it is a corrupt file in the perl package. We also tracked the UNH problem to something involving the evaluation of answers. I further tracked it to the pointers to the tree structures of MathObjects -- if you try to inspect them the server crashes. It might be an issue in MathObjects, but they haven't changed in some time.

My first suggestion is to see if there is anything on the net about perl builds for Gentoo. Keep in touch on the forums and let us know if there is any progress.

-- Mike
In reply to Michael Gage

Re: Apache2 Hangs When Loading Problem

by Geoff Goehle -
Thanks for the reply. Having something specific like MathObjects to latch on to is helpful.

As a side note, I have another problem, which may or may not be related. When I try to view a Problem which uses WWPlot I get:

Can't locate object method "imageName" via package "WWPlot" at line 125

Now, there isn't an object method named imageName in WWPlot, that particular method is handled by AUTOLOAD. So for some reason AUTOLOAD isn't working properly for Webwork.
In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Michael Gage -
If you send me a copy of the problem I'll take a look at it and see how it performs here. AUTOLOAD is the kind of perl gadget that could easily change with different versions of perl -- I've tried not to use it too much and if necessary we could eliminate its use in WWPlot. WWPlot itself has not been changed in some time to my knowledge. It could also be an indication that your copy of perl was incorrectly built which would also explain the loop error.

-- Mike (gage at math dot rochester do edu)

In reply to Michael Gage

Re: Apache2 Hangs When Loading Problem

by Geoff Goehle -
Its problem 2 of the demo set. But I get the same error with any problem using wwplot.

The error and problem code are below:

Error messages

Can't locate object method "imageName" via package "WWPlot" at line 125 of [PG]/macros/PGgraphmacros.pl Died within main::init_graph called at line 33 of [TMPL]/setDemo/limits.pg

Error details

 Problem2
ERROR caught by Translator while processing problem file:setDemo/limits.pg
****************
Can't locate object method "imageName" via package "WWPlot" at line 125 of [PG]/macros/PGgraphmacros.pl
 Died within main::init_graph called at line 33 of [TMPL]/setDemo/limits.pg

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

------Input Read
1 DOCUMENT(); # This should be the first executable line in the problem.
2
3 loadMacros(
4 "PGbasicmacros.pl",
5 "PGchoicemacros.pl",
6 "PGanswermacros.pl",
7 "PGgraphmacros.pl",
8 "PGauxiliaryFunctions.pl"
9 );
10
11 TEXT(&beginproblem);
12 $showPartialCorrectAnswers = 1;
13
14 $a=random(-3,3,1);
15 $b=random(-2,3,1);
16 $c=random(-3,2,1);
17 $m1=random(-1,1,0.5);
18 $m2=($b - $a)/2;
19 $m3=($c - $b - 1)/2;
20 $m4=random(-1,1,0.5);
21 @slice = NchooseK(3,3);
22
23 @colors = ("blue", "red", "green");
24 @sc = @colors[@slice]; #scrambled colors
25 @sa = ('A','B','C')[@slice];
26
27 $f1 = FEQ("${m1}(x+1) + $a for x in [-2,-1) using color:$sc[0] and weight:2");
28 $f2 = FEQ("${m2}(x-1) + $b for x in (-1,1) using color=$sc[0] and weight:2");
29 $f3 = FEQ("${m3}(x-3) + $c for x in [1,3) using color=$sc[0] and weight=2");
30 $f4 = FEQ("1+$a for x in [-1,-1] using color=$sc[0] and weight=2");
31 $f5 = FEQ("${m4}(x-3) + $c for x in (3,4] using color=$sc[0] and weight=2");
32
33 $graph = init_graph(-3,-6,5,6,'axes'=>[0,0],'grid'=>[8,12]);
34
35 ($f1Ref,$f2Ref,$f3Ref,$f4Ref,$f5Ref) = plot_functions($graph,$f1,$f2,$f3,$f4,$f5);
36
37 BEGIN_TEXT
38 Let F be the function below.$PAR
39 If you are having a hard time seeing the picture clearly, click on the picture. It will expand to a larger picture on its own page so that you can inspect it more clearly.$PAR
40 END_TEXT
41
42 TEXT(image( insertGraph($graph), height=>200, width=>200 ));
43
44 BEGIN_TEXT
45 $BR
46 $BR
47 Evaluate each of the following expressions. $PAR
48 Note: Enter 'DNE' if the limit does not exist or is not defined. $PAR
49
50 a) \( \lim_{x \to -1^-} F(x) \) = \{ans_rule(4)\}
51 $PAR
52
53 b) \( \lim_{x \to -1^+} F(x) \) = \{ans_rule(4)\}
54 $PAR
55
56 c) \( \lim_{x \to -1} F(x) \) = \{ans_rule(4)\}
57 $PAR
58
59 d) \( F(-1) \) = \{ans_rule(4)\}
60 $PAR
61
62 e) \( \lim_{x \to 1^-} F(x) \) = \{ans_rule(4)\}
63 $PAR
64
65 f) \( \lim_{x \to 1^+} F(x) \) = \{ans_rule(4)\}
66 $PAR
67
68 g) \( \lim_{x \to 1} F(x) \) = \{ans_rule(4)\}
69 $PAR
70
71 h) \( \lim_{x \to 3} F(x) \) = \{ans_rule(4)\}
72 $PAR
73
74 i) \( F(3) \) = \{ans_rule(4)\}
75 $PAR
76
77 END_TEXT
78
79 $ap1 = 1 + $a;
80 $bp1 = 1 + $b;
81
82 # limits at -1
83 ANS(num_cmp( [ $a, $a, $a, $ap1] , strings => ['DNE'] )) ;
84 # limits at 1
85 ANS(num_cmp( [ $b, $bp1,'DNE'] , strings => ['DNE'] )) ;
86 # limits at 3
87 ANS(num_cmp( [ $c, 'DNE' ] , strings => ['DNE'] )) ;
88
89
90 ENDDOCUMENT(); # This should be the last executable line in the problem.

In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Michael Gage -
Thanks.

that's a standard problem and is run on scores of sites. Just in case I pasted it into one of my test courses on hosted2.webwork.rochester.edu and was unable to get it to throw an error.

I think there is evidence that there is something funny about some part of the perl/apache installation.

-- Mike

In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Danny Glin -
I'm experiencing the same behaviour here. When I run WeBWorK on Scientific Linux 5.5 I get exactly what Geoff describes.
Our production machines are running on SL5.3, and things work fine on them. I tried a fresh up-to-date install of SL5.3, and I have the same problem with apache hanging.
Our production SL5.3 machines haven't had packages updated since last summer, so this leads me to believe that the problem lies in a perl package that was updated some time in the last year.
I'm probably going to try replacing some of the perl packages downloaded via yum to ones compiled via CPAN to see if I can track down the offending package.
In reply to Danny Glin

Re: Apache2 Hangs When Loading Problem

by Geoff Goehle -
The changes may be in the CPAN packages as well. The sysadmin at Dartmouth sent me the following reply. He solved his problems by replacing the CPAN packages with ubuntu .debs.

> Its tough to diagnose because there aren't a lot of error logs. Apache
> error logs are unhelpful. They just say that something timed out and
> hint there may be an infinite loop somewhere.
>
> When WW hangs trying to load a problem it does use up a bunch of
> resources. A couple of apache threads will take up 100% of a core or
> two.

This is what I experienced with Perl modules from CPAN. Unfortunately I
can't tell anymore which modules were the culprit. In the end I believe
I removed /usr/local/perl/ and /usr/local/share/perl/ altogether and
started installing distribution-provided versions. Then it was only
necessary to add Iterator and XML from CPAN. All worked fine after this.

In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Mark Hamrick -
Add me to the List, RHEL 5.5. Issue is appearing to be in PERL on my end also.

Thanks,
Mark
In reply to Mark Hamrick

Re: Apache2 Hangs When Loading Problem

by Gavin LaRose -
Hi Mark (et al.),

For those who are on RHEL machines, as we are, our experience is that the problem is that the 5.5 RHEL update takes Perl from 5.8.8-27.el5 to 5.8.8-32.el5_5.1. Safe.pm is in the default Perl package for RHEL, and this update takes Safe.pm to version 2.27, which (as noted by Geoff) is a problem. We found the simplest workaround to be to downgrade Perl back to 5.8.8-27.el5. This doesn't appear to adversely affect anything else (that we've seen, yet, at least).

Gavin
In reply to Gavin LaRose

Re: Apache2 Hangs When Loading Problem

by Mark Hamrick -
Hi Gavin- That is the solution that I came to late yesterday afternoon. The problem is that version of Perl has an issue if you are using SSL with LDAP. Therefore I had to downgrade Perl and force a reinstall of the Scaler Util package.
In reply to Gavin LaRose

Re: Apache2 Hangs When Loading Problem

by Jason Aubrey -
Here's the reason that particular module (Safe) was upgraded:

https://rhn.redhat.com/errata/RHSA-2010-0458.html

Jason
In reply to Jason Aubrey

Re: Apache2 Hangs When Loading Problem

by Geoff Goehle -
From redhat:

"The Safe module did not properly restrict the code of implicitly called
methods (such as DESTROY and AUTOLOAD) on implicitly blessed objects
returned as a result of unsafe code evaluation"

This explains why the AUTOLOAD portion of WWPlot was broken.
In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Geoff Goehle -
Good News Everyone!

After digging around I've found out that it is the Perl module "Safe" thats causing all of the problems.

On a test machine Webwork performs correctly with Safe version 2.19, (the penultimate stable version) but once I upgrade to version 2.27 I get _both_ problems mentioned in this post.

For now I'm downgrading Safe to 2.19, but it is a core module, so it would be worth tracking down what changed and why its breaking webwork.
In reply to Geoff Goehle

Re: Apache2 Hangs When Loading Problem

by Michael Gage -
Thanks very much Geoff. Safe.pm has always been a tricky module to deal with.

We'll try to track down the bad interaction but I can pretty much guarantee that it will take some time. Meantime move Safe back to version 2.19.
In reply to Michael Gage

Re: Apache2 Hangs When Loading Problem

by Jean-Marc Roy -
I think I have a problem that match this thread.

I've installed Fedora 13 on my test site server using WeBWorK release 2.4.5 with

Apache/2.2.15-1
mod_ssl/2.2.15-1
pyOpenSSL/0.9-1
PHP/5.3.2-2
gentoo/0.15.6-1
libapreq2/2.12-6
mod_perl/2.0.4-10
Perl/v5.10.1

The CPAN Safe module is version 2.27 - Fedora 13 was release in may 2010, it must have install a more recent version of Safe than 2.19 which date from mid 2009.

My WeBWorK site was working properly for at least a month till the beginning of August.

The WeBWorK web site still work properly, the problem occur when I want to render a problem - I get an infinite loop that use all of the system memory in less than 10 sec.

I try to downgrade to Safe 2.19 using a command like

cpan > install RGARCIA/Safe-2.19.tar.gz

but it fail.

I use the moodle integration - moodle question type (wwqt) and question server (wwqs). For the time being, I can use my main site question server (wwqs) on my test site server but the long term goal that the test server replace the mainserver. Fedora change version almost twice a year.

Am I correct to assume that the problem would be in the RenderProblem.pm file?

Thanks
In reply to Jean-Marc Roy

Re: Apache2 Hangs When Loading Problem

by Jean-Marc Roy -
I guess the problem is with the file Translator.pm in the pg folder. When I try to edit a problem of a data set the code run up to

line 346 $translator->translate();

of the file

/opt/webwork/webwork2/lib/WeBWorK/PG/Local.pm

Here $translator is an instantiation of the class WeBWorK::PG::Translator which is in the file

/opt/webwork/pg/lib/WeBWorK/PG/Translator.pm

and the subroutine translate is at line 793. I finally got an error from apache error_log which read

*** glibc detected *** /usr/sbin/httpd: double free or corruption (fasttop): 0x0288e9b8 ***

I will try to trace which lines in the translator are executed, but I feel that this may be over my head. I do coding as a hobby. If anyone has the solution to this riddle please post it before I consume another precious day on it.

NOTE: There are quite a bit of posting about the glibc double free. Look more like a consequence then a cause.
In reply to Jean-Marc Roy

Re: Apache2 Hangs When Loading Problem

by Jean-Marc Roy -
Closing in...

It is a Safe.pm problem not generic in nature. Everything work when I remove the ans_rule() from the problems. It may be specific to the macros in PGbasicmacros.pl more specifically with the line 133 an so on of the subroutine _PGbasicmacros_init where there is a transfer of the correct definitions in the main:: compartment to the local my variables. Not exactly sure what is happening here. Something to do with the share variable(s). Still exploring...

I'm trying to make some noise in order to get answers...
In reply to Jean-Marc Roy

Re: Apache2 Hangs When Loading Problem

by Michael Gage -
Hi Jean-Marc,

It is in fact the Safe.pm that causes the problems. The changes that they have made to Safe.pm for version 2.27 are not currently compatible with code use in MathObjects. The fix for now is to replace the Safe.pm version 2.27 with version 2.19.

Your first attempt in the post above is the way that I believe this is supposed to be done (I'm not an expert on cpan) but I have no idea why the installation failed. Perhaps you didn't issue the command from root (or sudo) in order to have enough permissions? I suggest that you go back and try again to replace the Safe.pm with the older version and see if that solves the problem.

-- Mike
In reply to Michael Gage

Re: Apache2 Hangs When Loading Problem

by Michael Gage -
For those who have been following this thread. Zig Fiedorowicz has reported to me that Safe.pm version 2.29 appears to be once again compatible with WeBWorK. I have installed it on our local systems and so far there has been no trouble.

We have, just in case, added a WWSafe.pm module to the WeBWorK software which can be used if your system's version of Safe is not compatible with WeBWorK. (To use it change the use Safe; line in pg/lib/WeBWorK/PG/Translator.pm to use WWSafe; )

The change log in the CPAN repository at http://search.cpan.org/~rgarcia/Safe-2.29/ reads:

2.29 Sun Oct 31 2010
 - Add &version::vxs::VCMP to Safe's default share

2.28 Mon Sep 13 2010
 - Avoid infinite loop in _find_code_refs.
 Patch by Yasushi Nakajima (rt.cpan.org #61262)
-- Mike