[NO-TICKET] Validate that all public symbols are prefixed in Ruby releases#573
Merged
[NO-TICKET] Validate that all public symbols are prefixed in Ruby releases#573
Conversation
…eases **What does this PR do?** This PR adds a check during packaging of Ruby releases that all symbols exported in the libdatadog shared library are correctly prefixed. **Motivation:** This allows us to catch any new unprefixed symbols, and thus we're able to rely on libdatadog not exporting symbols that would clash with other libraries that may be loaded in the same Ruby VM. **Additional Notes:** N/A **How to test the change?** You can observe the new check running with `docker-compose run push_to_rubygems`. This is safe to call as it'll stop asking for credentials before actually publishing anything to rubygems.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #573 +/- ##
==========================================
- Coverage 70.28% 70.24% -0.05%
==========================================
Files 214 214
Lines 28785 28802 +17
==========================================
Hits 20231 20231
- Misses 8554 8571 +17
|
BenchmarksComparisonBenchmark execution time: 2024-08-05 08:40:36 Comparing candidate commit 9533108 in PR branch Found 1 performance improvements and 1 performance regressions! Performance is the same for 40 metrics, 2 unstable metrics. scenario:normalization/normalize_trace/test_trace
scenario:tags/replace_trace_tags
CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
BaselineOmitted due to size. |
AlexJF
approved these changes
Aug 5, 2024
ivoanjo
added a commit
to DataDog/dd-trace-rb
that referenced
this pull request
Feb 6, 2025
**What does this PR do?** This PR removes the `datadog_profiling_loader` native extension, as it's no longer needed. The profiling native loader was added in #2003 . Quoting from that PR's description: > When Ruby loads a native extension (using `require`), it uses > `dlopen(..., RTLD_LAZY | RTLD_GLOBAL)` > (https://github.com/ruby/ruby/blob/67950a4c0a884bdb78d9beb4405ebf7459229b21/dln.c#L362). > > This means that every symbol exposed directly or indirectly by that > native extension becomes visible to every other extension in the > Ruby process. This can cause issues, see > rubyjs/mini_racer#179 . > > Ruby's extension loading mechanism is not configurable -- there's > no way to tell it to use different flags when calling `dlopen`. > To get around this, this commit introduces introduces another > extension (profiling loader) which has only a single responsibility: > mimic Ruby's extension loading mechanism, but when calling > `dlopen` use a different set of flags. > > This idea was shamelessly stolen from @lloeki's work in > rubyjs/mini_racer#179, big thanks! ...and importantly ends with: > Note that, that we know of, the profiling native extension only > exposes one potentially problematic symbol: > `rust_eh_personality` (coming from libddprof/libdatadog). > > Future versions of Rust have been patched not to expose this > (see rust-lang/rust#95604 (comment)) > so we may want to revisit the need for this loader in the future, > and perhaps delete it if we no longer require its services :) And we have reached the situation predicted in that description: 1. Nowadays libdatadog no longer exposes `rust_eh_personality` 2. We have a test that validates that only expected symbols are exported by the libdatadog library (see DataDog/libdatadog#573 ). Any new symbols that show up would break shipping new libdatadog versions to rubygems.org until we review them. 3. The `libdatadog_api` extension, which we've been shipping for customers since release 2.3.0 back in July 2024 has always been loaded directly without a loader without issues. Thus, I think it's the right time to get rid of the loader. **Motivation:** Having the loader around is not zero cost; we've run into/caused a few issues ( #2250 and #3582 come to mind). It also adds overhead to development: every time we need to rebuild the extensions, it's an extra extension that needs to be prepared, rebuilt, copied, etc. I've been meaning to get rid of the loader for some time now, and this came up again this week so I decided it was time to do it. **Additional Notes:** In the future, we can always ressurrect this approach if we figure out we need it again. We've also discussed internally about proposing upstream to the Ruby VM to maybe add an API to do what the loader was doing, so that we wouldn't need the weird workaround. We haven't yet decided if we're going to do that (help welcome!). **How to test the change?** The loader was responsible for loading the rest of profiling. Thus, any test that uses profiling was also validating the loader and now will validate that we're doing fine without it. TL;DR green CI is good.
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 adds a check during packaging of Ruby releases that all symbols exported in the libdatadog shared library are correctly prefixed.
Motivation
This allows us to catch any new unprefixed symbols, and thus we're able to rely on libdatadog not exporting symbols that would clash with other libraries that may be loaded in the same Ruby VM.
Additional Notes
N/A
How to test the change?
You can observe the new check running with
docker-compose run push_to_rubygems.This is safe to call as it'll stop asking for credentials before actually publishing anything to rubygems.