Add Ruby regexp program size patch for 3.3 and 3.4

Backports https://github.com/ruby/ruby/pull/19020 to Ruby 3.3 and 3.4.

  • 3.3: there is no upstream backport. The two upstream commits apply to Ruby 3.3.12 with line offsets only, and the change is identical to the 3.4 patch. Each commit keeps its upstream message plus a (cherry picked from commit ...) line.
  • 3.4: a verbatim copy of the upstream backport https://github.com/ruby/ruby/pull/19024 (still open upstream).
  • 4.0: not patched here yet.

RUBY_VERSION is 3.3.12 in ci_files/variables.yml, so the default gitlab-ruby image uses the 3.3 patch. apply_ruby_patches.sh applies every patch in the version directory, so no other file changes.

Testing locally

Run the gitlab-ruby image built from this branch:

docker run --rm registry.gitlab.com/gitlab-org/build/cng/gitlab-ruby:add-ruby-regexp-program-size-patch bash -c 'ruby -v; grep -q "too big compiled program" "$(ruby -rrbconfig -e "print File.join(RbConfig::CONFIG[%q(libdir)], RbConfig::CONFIG[%q(LIBRUBY_SO)])")" && echo patched || echo "not patched"'

It prints patched when libruby contains the new error message from the patch. The patch also adds a test to test/ruby/test_regexp.rb.

Verified in the built image

Pulled the gitlab-ruby image built from this branch and ran the command above. The gitlab-ruby job log shows patches/3.3/regexp-program-size.patch applied before the other 3.3 patches.

$ docker run --rm registry.gitlab.com/gitlab-org/build/cng/gitlab-ruby:add-ruby-regexp-program-size-patch bash -c '...'
ruby 3.3.12 (2026-07-16 revision 0581089df9) [x86_64-linux]
patched
Edited by Oleg Yakovenko

Merge request reports

Loading
Loading