Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-18924

infinite loop for some users: bug and solution suggested

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.4
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
      None
    • Environment:
      os: Linux CentOS v5.1, kernel 2.6.18-53.1.21
      web server: Apache v2.2.3-11
      php: v5.1.6-20
      MySql: v5.0.22
    • Database:
      MySQL
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE

      Description

      WHAT HAPPENS

      Some users (but not every time) experienced a problem displaying the questions for a test: only the first questions (two or three) is displayed.
      We have seen the problem with different clients (pc), different browsers (Ie, Firefox, Safari) and different server loads (also during the night).
      We have checked logs for os, Apache, MySql and have restarted web server and db: no help.
      Enabling debugging php shows:
      "Fatal error: Maximum execution time of 30 seconds exceeded in /usr/local/moodle/question/type/calculated/questiontype.php on line 1192"
      I have tried to raise `max_execution_time' parameter (to 5 minutes): same result, same line.

      HOW TO SKIP PROBLEM

      That line (1193) is part of the following loop:

      while ($answer < 1)

      { --$p10; $answer *= 10; }

      I asked to me: whatif $answer = 0 ? Answer: infinite loop.

      The test on $answer = 0 is located some lines above (line 1180)

      } else if ($answer) { // Significant figures does only apply if the result is non-zero

      I think it's a dangerous test (tons of words written on these kind of test).

      I have tried to substitute the test with

      } else if (round($answer, 8) != 0) {

      removing the risk to test a floating point variable. The problem vanished: everything's ok.

      Now I come back to the original code (with the problem) because I don't know if the patch creates side effects.

        Attachments

          Activity

            People

            Assignee:
            ppichet Pierre Pichet
            Reporter:
            marco.broglia Marco Broglia
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: