Problem/Motivation

Error: Maximum call stack size of 2048000 bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? in Drupal\Core\TypedData\TypedData->__sleep() (line 34 of core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php).

serialize() (Line: 14)
Drupal\Component\Serialization\PhpSerialize::encode() (Line: 120)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->doSetWithExpire() (Line: 131)
Drupal\Core\KeyValueStore\DatabaseStorageExpirable->setWithExpire() (Line: 143)
Drupal\Core\TempStore\PrivateTempStore->set() (Line: 76)
Drupal\layout_paragraphs\LayoutParagraphsLayoutTempstoreRepository->set() (Line: 60)

Steps to reproduce

This one is a bit tricky, you need hundreds of paragraphs_items, and the amount of bytes to process by the serialize also needs to be high. This will cause the in memory references of the $layout_paragraphs_layout to bloat while serialize is trying to handle the recursion loops and crash.

Proposed resolution

remove these recursive references before saving in LayoutParagraphsLayoutTempstoreRepository::set()

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

andras_szilagyi created an issue. See original summary.

andras_szilagyi’s picture

The version is 2.1.x because thats what I'm using but I might try to upgrade later to check results.

saidatom’s picture

Status: Active » Reviewed & tested by the community

Looks good, moving to RTBC.

saidatom’s picture

Status: Reviewed & tested by the community » Needs review

unsetting _referringItem on the live paragraph objects; fixed by re-linking them after the tempstore write and read.

alorenc’s picture

Status: Needs review » Needs work

The pipeline failed for the latest changes, so it’s difficult to say whether everything is working correctly.

alorenc’s picture

saidatom’s picture

The test failures are pre-existing and unrelated to this change — they're caused by the missing #[RunTestsInSeparateProcesses]

alorenc’s picture

alorenc’s picture

Very likely, this work will conflict with #3611711

alorenc’s picture

Created the 3599833-3.0.x-maximum-call-stack branch and cherry-picked the changes from the other branch to check the test results.

alorenc’s picture

alorenc’s picture

Reordering components left each paragraph pointing at the wrong field item. Those wrong pointers chained all the paragraphs together, so saving the layout recursed through every paragraph and ran out of stack on big pages.

The fix updates the pointers after each reorder.

alorenc’s picture

Assigned: andras_szilagyi » Unassigned
alorenc’s picture

Status: Needs work » Needs review

alorenc changed the visibility of the branch 3599833-3.0.x-maximum-call-stack to hidden.

dimilias’s picture

Status: Needs review » Reviewed & tested by the community

Tested on the UI and the code looks fine. +1 RTBC.