[PROF-13445] Fix Ruby 4.0.1 picking 4.0.0-preview2 headers and bump gem version to 3.5.1#25
Merged
Merged
Conversation
…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.
Strech
approved these changes
Jan 13, 2026
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.
This was referenced Jan 14, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::Versiontreating any suffixes as non-stable versions (including thep0).Thus
4.0.0.preview2>4.0.0.p0because between non-stable versions it sorts on string (andpreviewcomes afterp0); 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-preview3would fall back to4.0.0-preview2and that didn't work correctly; and this PR actually fixes that as a side-effect:4.0.0-preview3will 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.