Skip to content

[PROF-13445] Fix Ruby 4.0.1 picking 4.0.0-preview2 headers and bump gem version to 3.5.1#25

Merged
ivoanjo merged 3 commits into
masterfrom
ivoanjo/prof-13445-fix-wrong-headers-4_0_1
Jan 13, 2026
Merged

[PROF-13445] Fix Ruby 4.0.1 picking 4.0.0-preview2 headers and bump gem version to 3.5.1#25
ivoanjo merged 3 commits into
masterfrom
ivoanjo/prof-13445-fix-wrong-headers-4_0_1

Conversation

@ivoanjo

@ivoanjo ivoanjo commented Jan 13, 2026

Copy link
Copy Markdown
Member

What does this PR do?

This PR fixes a bug in the "fuzzy" matching of headers to Ruby versions, where Ruby 4.0.1 would incorrectly fall back to 4.0.0-preview2 headers INSTEAD of 4.0.0 stable headers.

It also bumps the gem version so we can get this fix out ASAP before we cause issues to customers upgrading to 4.0.1 and later.

Motivation:

Fix support for Ruby > 4.0.0.

Additional Notes:

This bug lay dormant for a long time, as usually we didn't ship at the same time preview/rc headers and stable headers. But because dd-trace-rb CI is still running on 4.0.0-preview2, we kept both this time and so the bug came and said hi.

The issue boils down to Gem::Version treating any suffixes as non-stable versions (including the p0).

Thus 4.0.0.preview2 > 4.0.0.p0 because between non-stable versions it sorts on string (and preview comes after p0); eliminating the useless prefix for stable Rubies avoids this.

Interestingly, in #24 I mentioned that we had a slight sharp edge where 4.0.0-preview3 would fall back to 4.0.0-preview2 and that didn't work correctly; and this PR actually fixes that as a side-effect: 4.0.0-preview3 will now fall back to the stable headers, which is actually correct.

How to test the change?

Since the gem didn't previously have tests I bootstrapped some quickly so I could add test coverage for this change.

…em version to 3.5.1

**What does this PR do?**

This PR fixes a bug in the "fuzzy" matching of headers to Ruby
versions, where Ruby 4.0.1 would incorrectly fall back to
4.0.0-preview2 headers INSTEAD of 4.0.0 stable headers.

It also bumps the gem version so we can get this fix out ASAP before
we cause issues to customers upgrading to 4.0.1 and later.

**Motivation:**

Fix support for Ruby > 4.0.0.

**Additional Notes:**

This bug lay dormant for a long time, as usually we didn't ship at
the same time preview/rc headers and stable headers. But because
dd-trace-rb CI is still running on 4.0.0-preview2, we kept both
this time and so the bug came and said hi.

The issue boils down to `Gem::Version` treating any suffixes as
non-stable versions (including the `p0`).

Thus `4.0.0.preview2` > `4.0.0.p0` because between non-stable
versions it sorts on string (and `preview` comes after `p0`);
eliminating the useless prefix for stable Rubies avoids this.

Interestingly, in #24 I mentioned that we had a slight sharp edge
where `4.0.0-preview3` would fall back to `4.0.0-preview2` and that
didn't work correctly; and this PR actually fixes that as a side-effect:
`4.0.0-preview3` will now fall back to the stable headers, which is
actually correct.

**How to test the change?**

Since the gem didn't previously have tests I bootstrapped some
quickly so I could add test coverage for this change.
@ivoanjo
ivoanjo merged commit 7f3dded into master Jan 13, 2026
37 checks passed
@ivoanjo
ivoanjo deleted the ivoanjo/prof-13445-fix-wrong-headers-4_0_1 branch January 13, 2026 11:55
ivoanjo added a commit to DataDog/dd-trace-rb that referenced this pull request Jan 14, 2026
**What does this PR do?**

This PR bumps the minimum version of the datadog-ruby_core_source gem to
the latest version (3.5.1), having the usual diff (e.g. #5215 was the
previous update).

**Motivation:**

Doing this bump forces updates to the `datadog` gem to also pull in the
latest version of the `datadog-ruby_core_source` gem. This ensures
users have the best experience and don't e.g. run into issues because
somehow they're running the latest version of the gem with an outdated
version of the headers.

Specifically version 3.5.1 brings a fix where Ruby 4.0.1 and above
would pick the wrong headers to use
(DataDog/datadog-ruby_core_source#25)
which could result in crashes or incorrect behavior when using the
profiler.

(It also fixes support for Ruby 4.0.0-preview3 but that's not really
very interesting.)

**Additional Notes:**

This PR is on top of #5234 just to avoid any conflicts when touching
the gemfiles but is otherwise completely separate.

**How to test the change?**

These headers are used by the profiler, so green CI means we're good to go.

I've also manually checked with Ruby 4.0.1, 4.0.0 and some other earlier
versions to make sure everything is in good shape.
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.

2 participants