Skip to content

Segmentation fault in lib/gitlab/git/repository.rb:121

We've been seeing about one seg fault a day on Sidekiq: https://log.gprd.gitlab.net/goto/4eddce60-81bb-11ed-85ed-e7557b0a598c

/srv/gitlab/lib/gitlab/git/repository.rb:121: [BUG] Segmentation fault at 0x0000000000000010

Unfortunately getting the straight dump of the error messages is difficult, but attached is a not-very-well-ordered CSV of log entries for one event:

repo-seg-fault.csv

The code in question:

      # Returns an Array of branch names
      # sorted by name ASC
      def branch_names
        refs = list_refs([Gitlab::Git::BRANCH_REF_PREFIX])

        refs.map { |ref| Gitlab::Git.branch_name(ref.name) }
      end

@proglottis I see this was recently changed in !106249 (merged).

In https://github.com/pganalyze/pg_query/pull/227, I recall with Array#concat we needed to call to_a to prevent the Ruby garbage collector from prematurely removing the array. I wonder if this is related to https://bugs.ruby-lang.org/issues/18140, but I don't see any indication the seg fault is happening in the garbage collector.