-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NO-TICKET] Add memory leak testing for profiling + fix (small) memory leak in profiler #3852
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6ba1e5f
Bootstrap support for running profiling tests with ruby_memcheck
ivoanjo 252ce6b
Avoid leaking memory in stack collector spec
ivoanjo 451a6ba
Fix memory leak when Ruby process used fork
ivoanjo bf84177
Ignore any leaks reported from pkg-config, since we don't control it
ivoanjo df9b242
Avoid leaking memory in stack collector spec when max_frames is invalid
ivoanjo 94fa2c4
Fix exception in ruby 3.4 development builds
ivoanjo 8f35a5e
Add suppression for Ruby leaking thread data in a fork
ivoanjo 5f48a9b
Fix profiler spec by using webrick from git on Ruby 3.4
ivoanjo 92e8dd5
Add another suppression for Ruby native thread leak for Ruby 3.4.0-pr…
ivoanjo e188e32
Add GitHub Action for testing for memory leaks in CI
ivoanjo 877abf3
Install valgrind in CI before using it
ivoanjo 1688da4
Confirm that suppressions folder is expected not to be packaged
ivoanjo a8ee486
Make rubocop happy
ivoanjo 9785a30
Use ubuntu 24.04 as a base image to get latest valgrind
ivoanjo b1dc345
Add suppression for tr tool
ivoanjo 168452e
Empty commit to re-trigger CI
ivoanjo c8f2338
Attempt to fix flaky spec due to timing issues
ivoanjo 5bc00e1
Update gc benchmark with new argument on test method
ivoanjo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Test for memory leaks | ||
on: [push] | ||
jobs: | ||
test-memcheck: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.4.0-preview1 # TODO: Use stable version once 3.4 is out | ||
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | ||
bundler: latest | ||
cache-version: v1 # bump this to invalidate cache | ||
- run: sudo apt install -y valgrind && valgrind --version | ||
- run: bundle exec rake compile spec:profiling:memcheck |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
|tasks | ||
|yard | ||
|vendor/rbs | ||
|suppressions | ||
)/ | ||
}x | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# This is a valgrind suppression configuration file. | ||
# | ||
# We use it together with the ruby_memcheck gem to find issues in the dd-trace-rb native extensions; in some cases | ||
# we need to ignore potential issues as they're not something we can fix (e.g. outside our code.) | ||
# | ||
# See https://valgrind.org/docs/manual/manual-core.html#manual-core.suppress for details. | ||
|
||
# Ruby weak maps seem to be able to cause invalid reads? | ||
{ | ||
ruby-weak-map | ||
Memcheck:Addr8 | ||
fun:wmap_cmp | ||
fun:find_table_bin_ind | ||
fun:st_general_foreach | ||
fun:rb_st_foreach | ||
... | ||
} | ||
|
||
# When a Ruby process forks, it looks like Ruby doesn't clean up the memory of old threads? | ||
{ | ||
ruby-native-thread-memory | ||
Memcheck:Leak | ||
fun:calloc | ||
fun:calloc1 | ||
fun:rb_gc_impl_calloc | ||
fun:native_thread_alloc | ||
fun:native_thread_create_dedicated | ||
fun:native_thread_create | ||
fun:thread_create_core | ||
... | ||
} | ||
|
||
# When a Ruby process forks, it looks like Ruby doesn't clean up the memory of old threads? | ||
{ | ||
ruby-native-thread-memory-2 | ||
Memcheck:Leak | ||
fun:calloc | ||
fun:calloc1 | ||
fun:objspace_xcalloc | ||
fun:ruby_xcalloc_body | ||
fun:native_thread_alloc | ||
fun:native_thread_create_dedicated | ||
fun:native_thread_create | ||
fun:thread_create_core | ||
... | ||
} | ||
|
||
# We don't care about the pkg-config external tool | ||
{ | ||
pkg-config-memory | ||
Memcheck:Leak | ||
... | ||
obj:/usr/bin/pkg-config | ||
... | ||
} | ||
|
||
# We don't care about the tr external tool | ||
{ | ||
pkg-config-memory | ||
Memcheck:Leak | ||
... | ||
obj:/usr/bin/tr | ||
... | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't seem to find any code overriding this state. Why do we need to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See commit description for c8f2338 -- it's my attempt at fixing a flaky spec that showed up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack! (not used to seeing useful commit descriptions 😂 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥🔥🔥