Skip to content

Fix SystemStackError when Peek bar is active with Rugged calls

Stan Hu requested to merge sh-fix-infite-loop-peek-bar into master

Peek attempts to serialize results with to_json, which calls ActiveSupport::JSON. If an object is passed to to_json that contains instance variables, ActiveSupport will attempt to recursively traverse all variables.

The problem is that we can get into an infinite loop if the instance references to an instance that references to something else that points back to the same instance.

To avoid this mess, we just call to_s on the object if it has instance variables. It appears only Gitlab::Git::Repository and ::Repository are the culprits here.

A better explanation is here: https://engineering.sequra.es/2015/07/que-json-activesupport-and-stack-level-too-deep/

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/65404

Edited by Stan Hu

Merge request reports