Skip to content

Ruby 3.2 Upgrade#13

Open
calh wants to merge 10 commits intomikeowens:masterfrom
calh:ruby32_upgrade2
Open

Ruby 3.2 Upgrade#13
calh wants to merge 10 commits intomikeowens:masterfrom
calh:ruby32_upgrade2

Conversation

@calh
Copy link

@calh calh commented Oct 24, 2025

This is a PR on top of #12, so review and merge that one first before considering this.

There are significant changes from Ruby 2 to Ruby 3 and I needed help. I tried out OpenAI's Codex and was pretty impressed with it. Read more about my thoughts in d5e0faf.

I'm still testing this out in a development environment, but so far it seems like the Codex patch is working well!

calh added 10 commits September 22, 2025 10:42
The differences between Ruby 2 and Ruby 3 are significant
in terms of thread safety and memory safety.  I (Cal) have not
worked with the Ruby SDK very much in the past.  There
is not much documentation for C++ embedders to use, especially
concerning the newer Ruby versions.

So I decided to try out OpenAI's Codex CLI.  I gave it access
to all of Ruby 3.2's source and headers, along with a mechanism
to compile and test ModRuby on a live Apache server.

I showed it the segfault back trace in rb_protect() and told it
to resolve the issue.  It spent a total of around an hour
doing web searches, reading the source and trying things out.
It made mistakes, spotted its own errors, then recompiled and retested
until it had success.

I've scanned over this commit and I don't see any obvious problems
with it.

There were two main issues here for the Ruby 3 port:

1) You can't call rb_protect() without a global VM lock
2) You can't get the global VM lock from a thread outside of Ruby
   (IE:  In an Apache MPM thread)

Fixing #1 caused #2.  The RubyDispatcher class shifts interaction
with Ruby to an interface that manages the global VM.  rb_protect()
is wrapped in a GVL so that native C++ functions can interact
with Ruby objects and methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant