Infinite loop on drupal menu

Created on 16 December 2024, about 1 month ago

Problem/Motivation

We updated our drupal core to 10.2.8, then on release it to our customer we noticed that in some roles if user had only that role system returns 503 of every request. The only 3 possibles cenΓ‘rios that were able to login and use system was:
just logged user (with no special role)
just admin
just content editor (viewer)

users with any other roles where receiving this error.

This error occurs on version 10.3.x too of drupal core for me.

Steps to reproduce

Actually I don't know how to reproduce it exactly, but I was using php 8.2 and was receiving no error, when updating to 8.3 I could verify the error message:

 "%type" => "Error"
  "@message" => "Maximum call stack size of 8339456 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?"
  "%function" => "Drupal\Core\Menu\MenuTreeParameters->__serialize()"
  "%file" => "/var/www/html/docroot/core/lib/Drupal/Core/Menu/MenuTreeParameters.php"
  "%line" => 231
  "severity_level" => 3
  "backtrace" => array:82121 []
  "@backtrace_string" => """
    #0 [internal function]: Drupal\Core\Menu\MenuTreeParameters->__serialize()

    #1 /var/www/html/docroot/core/lib/Drupal/Core/Menu/MenuTreeStorage.php(827): serialize()

    #2 /var/www/html/docroot/core/lib/Drupal/Core/Menu/MenuLinkTree.php(102): Drupal\Core\Menu\MenuTreeStorage->loadTreeData()

    #3 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(105): Drupal\Core\Menu\MenuLinkTree->load()

    #4 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

    #5 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

    #6 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()

    #7 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()

    #8 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()

    #9 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(106): Drupal\Core\Access\AccessManager->checkNamedRoute()

    #10 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

    #11 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

    #12 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()

    #13 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()

    #14 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()

    #15 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(106): Drupal\Core\Access\AccessManager->checkNamedRoute()

    #16 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

    #17 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

    #18 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()

    #19 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()

    #20 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()

    #21 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(106): Drupal\Core\Access\AccessManager->checkNamedRoute()

    #22 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

    #23 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

    #24 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()

    #25 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()

    #26 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()

    #27 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(106): Drupal\Core\Access\AccessManager->checkNamedRoute()

    #28 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

    #29 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

    #30 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()

    #31 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()

    #32 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()

    #33 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(106): Drupal\Core\Access\AccessManager->checkNamedRoute()

    #34 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

    #35 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

There was a loop in the menu module, since I was updating to drupal core 10.3.0, 10.3.1 untill 10.3.8 I could verify that all this versions has the same issue, in some cases the start of stack trace could start at diferent points but there is a loop in this files/funcitons:

 #11 [internal function]: Drupal\system\Access\SystemAdminMenuBlockAccessCheck->access()

    #12 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()

    #13 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()

    #14 /var/www/html/docroot/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()

    #15 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(106): Drupal\Core\Access\AccessManager->checkNamedRoute()

    #16 /var/www/html/docroot/core/modules/system/src/Access/SystemAdminMenuBlockAccessCheck.php(79): Drupal\system\Access\SystemAdminMenuBlockAccessCheck->hasAccessToChildMenuItems()

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

10.2 ✨

Component

menu.module

Created by

πŸ‡§πŸ‡·Brazil andrelzgava

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @andrelzgava
  • Is Xdebug enabled when this occurs?

  • Merge request !105773494287 - prevent menu loop β†’ (Open) created by Unnamed author
  • Pipeline finished with Success
    about 1 month ago
    Total: 440s
    #370245
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Drupal 10.2 is no longer receiving support. Does this problem occur on currently supported versions of Drupal?

    Since we need more information to move forward with this issue, I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡¨πŸ‡¦Canada Charlie ChX Negyesi 🍁Canada

    zend.max_allowed_stack_size is a new feature in PHP 8.3 and apparently 8M is just not cutting it with a larger menu. Try disabling it with zend.max_allowed_stack_size = -1 and if that clears the error as it should then you could experiment with it until you find a good value. If it doesn't clear the error then indeed there's a bug.

    I fully expect this to be a widespread problem and perhaps core devs should document it albeit I am unsure where. Perhaps default.settings.php ? I am actually surprised more reports haven't been sent about this.

  • πŸ‡¬πŸ‡§United Kingdom catch

    We could add a hook_requirements() that warns under a certain number, we've got similar things for memory limit and etc.

    But also really wonder what size menu is triggering this?

Production build 0.71.5 2024