Skip to content

Ruby 3.2 Upgrade#2

Merged
calh merged 6 commits intomasterfrom
ruby32_upgrade2
Oct 24, 2025
Merged

Ruby 3.2 Upgrade#2
calh merged 6 commits intomasterfrom
ruby32_upgrade2

Conversation

@calh
Copy link
Owner

@calh calh commented Oct 24, 2025

No description provided.

calh added 6 commits October 24, 2025 09:51
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.
@calh calh merged commit 40a8d78 into master Oct 24, 2025
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