Miscellaneous

Crash due to 'while loop' and "show me another"?

Crash due to 'while loop' and "show me another"?

by Stacey Rodman -
Number of replies: 2

We have recently had WeBWorK crash several times. It seems to be related to a specific problem, that involves a while loop:

$a = random(-5,5,1);
$b = random(-5,5,1);
while ($a == $b) { $b = random(-5,5,1); }  # make sure curl is not = 0

Error detected while loading [PG]/macros/contextTypeset.pl:\nPG_macro_file_eval detected error at line 123 of file [PG]/lib/PGloadfiles.pm \nTimeout after processing this problem for 60 seconds. Check for infinite loops in problem source.

Could it be a combination of this while loop and the efforts of "show me another" to produce a different problem?  Is there a fix? 

Thanks!

In reply to Stacey Rodman

Re: Crash due to 'while loop' and "show me another"?

by Danny Glin -

That particular while loop shouldn't ever take more than a few iterations to complete, so I wouldn't expect that to be the cause of the timeout.

Can you post the full problem code?  It's possible that there is an issue somewhere else.

In reply to Danny Glin

Re: Crash due to 'while loop' and "show me another"?

by Stacey Rodman -

Full code:

DOCUMENT();
loadMacros(
  "PGstandard.pl",
  "PGchoicemacros.pl",
  "PGcourse.pl",
  "MathObjects.pl",
 );
 
Context('Vector');

$a = random(-5,5,1);
$b = random(-5,5,1);
while ($a == $b) { $b = random(-5,5,1); }  # make sure curl is not = 0
$c = random(-5,5,1);
$d = random(-5,5,1);
$e = random(-5,5,1);
$f = random(-5,5,1);

$f1 = nicestring([$a,  $d],[ 'y', 'z']);
$f2 = nicestring([$b,  $e],[ 'x', 'z']);
$f3 = nicestring([$c,  $f],[ 'x', 'y']);

$curl = Vector( $f-$e, $d-$c, $b-$a );

$p1 = non_zero_random(-5,5,1);
$p2 = random(-5,5,1);
$p3 = random(-5,5,1);

$v1 = random(-5,5,1);
$v2 = random(-5,5,1);
$v3 = non_zero_random(-5,5,1);

$vector = Vector($v1, $v2, $v3);

$rotation = $curl.$vector/norm($vector);
Context('Numeric');
##
TEXT(beginproblem());

BEGIN_TEXT  
Consider the vector field 
\( \vec{F}(x,y,z) = \langle $f1, $f2, $f3 \rangle \).
$BR
Find the divergence and curl of \(\vec{F} \).  Use <  >  for vectors. 
$BR
$BR
\( \textrm{div}(\vec{F}) = \) \{ans_rule(20)\}.
$BR
\( \textrm{curl}(\vec{F}) = \) \{ans_rule(20)\}.
$BR
$BR
What is the "right-hand" rotation of \(\vec{F}\) at the point \( ($p1,$p2,$p3 ) \)  around the vector \( \langle $v1, $v2, $v3 \rangle \)
$BR
$BR
\(\textrm{rotation} = \) \{ans_rule(20)\}.

END_TEXT

ANS(num_cmp(0));
ANS($curl->cmp());
ANS($rotation->cmp());

ENDDOCUMENT();