Add Ruby regexp repeat-range double-free patch for 3.3 and 3.4
Backports https://github.com/ruby/ruby/pull/13332 to Ruby 3.3 and 3.4. Parsing a regexp with a too-big repetition quantifier (e.g. Regexp.new("|{2,1}")) frees the same parse node twice and aborts the process instead of raising RegexpError. Fixed upstream in Ruby 4.0, so ruby.rb applies the patch only for versions >= 3.3.0 and < 4.0.0.
Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/628985
Testing locally
Build a package from this branch (Ruby 3.3 or 3.4), install it, then run the embedded Ruby:
/opt/gitlab/embedded/bin/ruby -e 'begin; Regexp.new("|{2,1}"); puts "NOT PATCHED (no error raised)"; rescue RegexpError => e; puts "rescued RegexpError: #{e.message}"; end'
/opt/gitlab/embedded/bin/ruby -e 'begin; eval("/|{1000000}/"); rescue SyntaxError => e; puts "rescued SyntaxError: #{e.message.lines.first.strip}"; end'With the patch both commands print a rescued line and exit 0. Without the
patch the first aborts the process (Aborted, exit 134). Expected output:
rescued RegexpError: upper is smaller than lower in repeat range: /|{2,1}/
rescued SyntaxError: (eval at -e:1):1: too big number for repeat range: /|{1000000}/Verified in the built image
Pulled the branch package image on a Linux host and confirmed the patched embedded Ruby raises rescuable errors (exit 0; an unpatched Ruby aborts with exit 134). This branch build used Ruby 3.4, so it exercises the 3.4 patch:
$ docker run --rm --entrypoint /opt/gitlab/embedded/bin/ruby \
registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ee:19.4.0-rfbranch.2850941630.43d61a9a-0-amd64 -v
ruby 3.4.10 (2026-06-30 revision 2b0b7728dc) +PRISM [x86_64-linux]
rescued RegexpError: upper is smaller than lower in repeat range: /|{2,1}/
rescued SyntaxError: (eval at -e:1):1: too big number for repeat range: /|{1000000}/