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

Infinite recursion while asynchronous course restore

      To reproduce:

      • Enable enableasyncbackup config
      • Create a new course and add some activities
      • Create a backup of this course
      • Create another course
      • Restore the created backup mbz file into this course
      • Cleanup everything in the backup temp directory
      • Run cron
      • You will see the adhoc task for restoring the course to fail with a segfault or - with xdebug enabled - the process will be killed because it reaches the stack size limit (no matter how high it is configured):

      1712903744.0445 974 ===== Execute adhoc task: core\task\asynchronous_restore_task
      1712903744.0445 974 ===== Adhoc task id: 142
      1712903744.0445 974 ===== Adhoc task custom data: {"backupid":"f65c7831afe9246714c4d11d7c53eba5"}
      1712903744.0461 974 ===== ... started 08:35:44. Current memory use 62.4 MB.
      1712903744.0476 974 ===== Processing asynchronous restore for id: f65c7831afe9246714c4d11d7c53eba5
      loading controller from db
      setting controller status to 800
      saving controller to db
      calculating controller checksum 0536de00f28c9bfaff0be2ffa5b3e56d
      loading controller from db
      setting controller status to 900
      saving controller to db
      Segmentation fault (core dumped) 

      Yes, it should be pretty rare that this issue appears, because files and directories in the backup temp dir will only be removed after a week, but I guess this will also happen if there is some issue when extracting the backups or some files are broken (I could not dig deeper what exactly is causing the infinite loop), but this job should not segfault at any point.

      It's even worse: If this job segfaults, it eventually will leave locks unreleased, so other tasks will not be spawned anymore.

      Tested on latest main branch and moodle 4.3, I assume versions below suffer from the same issue.

      In addition to that it seems that the target course after that now is broken, there is a Attempt to read property "id" on null error being shown when accessing the course.

      A little bit more digging with xdebug shows that the infinite loop is caused by the recursion in backup_general_helper::array_checksum_recursive.

            Votes:
            11 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.