ruby_memcheck 1.1.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +14 -1
- data/README.md +20 -12
- data/lib/ruby_memcheck/configuration.rb +15 -3
- data/lib/ruby_memcheck/frame.rb +6 -5
- data/lib/ruby_memcheck/rspec/rake_task.rb +1 -0
- data/lib/ruby_memcheck/test_helper.rb +3 -0
- data/lib/ruby_memcheck/test_task.rb +1 -0
- data/lib/ruby_memcheck/valgrind_error.rb +1 -1
- data/lib/ruby_memcheck/version.rb +1 -1
- data/suppressions/ruby.supp +6 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fca269c41420864e19c468ac6d8c0101624f7c8638b603f2cf6975acbcc9f6b6
|
4
|
+
data.tar.gz: ea928aef070c76ab183cc80592e0ad8ecf3cbb2c5550f4dacd4ea143c0096d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7049b31e3177ab265ae4f67318cb3c95ef9332091eea013af93a636662e4350190d02a0f6a8d571755e0df9031ba20a59624c133b07dbf57a3af04929da374e
|
7
|
+
data.tar.gz: 8e210f743656f5c604103f113574f2957f37666b2ba52ba350ee94680a34fbb61ade1ccd535b6145f268c280c29082b50c2133b3d1b4c32a9ba19c83c9b1af65
|
data/.github/workflows/test.yml
CHANGED
@@ -4,11 +4,13 @@ jobs:
|
|
4
4
|
test:
|
5
5
|
runs-on: ubuntu-latest
|
6
6
|
strategy:
|
7
|
+
fail-fast: false
|
7
8
|
matrix:
|
8
9
|
entry:
|
9
10
|
- { ruby: '2.7', allowed-failure: false }
|
10
11
|
- { ruby: '3.0', allowed-failure: false }
|
11
12
|
- { ruby: '3.1', allowed-failure: false }
|
13
|
+
- { ruby: '3.2', allowed-failure: false }
|
12
14
|
- { ruby: ruby-head, allowed-failure: false }
|
13
15
|
name: ruby ${{ matrix.entry.ruby }}
|
14
16
|
steps:
|
@@ -16,7 +18,18 @@ jobs:
|
|
16
18
|
- uses: ruby/setup-ruby@v1
|
17
19
|
with:
|
18
20
|
ruby-version: ${{ matrix.entry.ruby }}
|
19
|
-
- run: sudo apt-get install -y valgrind
|
21
|
+
# - run: sudo apt-get install -y valgrind
|
22
|
+
# We cannot use Valgrind from apt because we need at least Valgrind 3.20.0
|
23
|
+
# to support DWARF 5
|
24
|
+
- run: sudo apt-get install -y libc6-dbg
|
25
|
+
- name: Install Valgrind from source
|
26
|
+
run: |
|
27
|
+
wget https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2
|
28
|
+
tar xvf valgrind-3.20.0.tar.bz2
|
29
|
+
cd valgrind-3.20.0
|
30
|
+
./configure
|
31
|
+
make
|
32
|
+
sudo make install
|
20
33
|
- run: bundle install --jobs=3 --retry=3
|
21
34
|
- run: bundle exec rake
|
22
35
|
continue-on-error: ${{ matrix.entry.allowed-failure }}
|
data/README.md
CHANGED
@@ -50,6 +50,25 @@ gem install ruby_memcheck
|
|
50
50
|
|
51
51
|
## Setup
|
52
52
|
|
53
|
+
> **Note**
|
54
|
+
> If you encounter errors from Valgrind that looks like this:
|
55
|
+
> ```
|
56
|
+
> ### unhandled dwarf2 abbrev form code 0x25
|
57
|
+
> ```
|
58
|
+
> Then you need a newer version of Valgrind (>= 3.20.0) with DWARF5 support.
|
59
|
+
> The current versions of Valgrind in Ubuntu Packages is not new enough.
|
60
|
+
>
|
61
|
+
> You can install Valgrind from source using the following commands:
|
62
|
+
> ```
|
63
|
+
> sudo apt-get install -y libc6-dbg
|
64
|
+
> wget https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2
|
65
|
+
> tar xvf valgrind-3.20.0.tar.bz2
|
66
|
+
> cd valgrind-3.20.0
|
67
|
+
> ./configure
|
68
|
+
> make
|
69
|
+
> sudo make install
|
70
|
+
> ```
|
71
|
+
|
53
72
|
The easiest way to use this gem is to use it on your test suite (minitest or RSpec) using rake.
|
54
73
|
|
55
74
|
0. Install Valgrind.
|
@@ -121,18 +140,6 @@ The easiest way to use this gem is to use it on your test suite (minitest or RSp
|
|
121
140
|
end
|
122
141
|
```
|
123
142
|
|
124
|
-
1. Add the following line to your `test_helper.rb` or `spec_helper.rb`:
|
125
|
-
|
126
|
-
```ruby
|
127
|
-
at_exit { GC.start }
|
128
|
-
```
|
129
|
-
|
130
|
-
This will run a major garbage collection cycle before the Ruby process shuts down. This will ensure that any remaining Ruby objects are collected which will prevent Valgrind from reporting false positives.
|
131
|
-
|
132
|
-
It is safest to add the line above at the very first line of `test_helper.rb` or `spec_helper.rb`.
|
133
|
-
|
134
|
-
- **For minitest:** It is important that the line above is added BEFORE the `require "minitest/autorun"` line.
|
135
|
-
|
136
143
|
1. You're ready to run your test suite with Valgrind using `rake test:valgrind` or `rake spec:valgrind`! Note that this will take a while to run because Valgrind will make Ruby significantly slower.
|
137
144
|
1. (Optional) If you find false positives in the output, you can create Valgrind suppression files. See the [`Suppression files`](#suppression-files) section for more details.
|
138
145
|
|
@@ -151,6 +158,7 @@ When you run `RubyMemcheck.config`, you are creating a default `RubyMemcheck::Co
|
|
151
158
|
- `skipped_ruby_functions`: Optional. Ruby functions that are ignored because they are considered a call back into Ruby. This is only present as an escape hatch, so avoid using it. If you find another Ruby function that is a false positive because it calls back into Ruby, please send a patch into this repo. Otherwise, use a Valgrind suppression file.
|
152
159
|
- `valgrind_xml_dir`: Optional. The directory to store temporary XML files for Valgrind. It defaults to a temporary directory. This is present for development debugging, so you shouldn't have to use it.
|
153
160
|
- `output_io`: Optional. The `IO` object to output Valgrind errors to. Defaults to standard error.
|
161
|
+
- `filter_all_errors`: Optional. Whether to filter all kinds of Valgrind errors (not just memory leaks). This feature should only be used if you're encountering a large number of illegal memory accesses coming from Ruby. If you need to use this feature, you may have found a bug inside of Ruby. Consider reporting it to the [Ruby bug tracker](https://bugs.ruby-lang.org/projects/ruby-master/issues/new). Defaults to `false`.
|
154
162
|
|
155
163
|
## Suppression files
|
156
164
|
|
@@ -31,9 +31,19 @@ module RubyMemcheck
|
|
31
31
|
/\Arb_yield/,
|
32
32
|
].freeze
|
33
33
|
|
34
|
-
attr_reader :binary_name
|
35
|
-
|
34
|
+
attr_reader :binary_name
|
35
|
+
attr_reader :ruby
|
36
|
+
attr_reader :valgrind
|
37
|
+
attr_reader :valgrind_options
|
38
|
+
attr_reader :valgrind_suppression_files
|
39
|
+
attr_reader :valgrind_generate_suppressions
|
40
|
+
attr_reader :skipped_ruby_functions
|
41
|
+
attr_reader :valgrind_xml_dir
|
42
|
+
attr_reader :output_io
|
43
|
+
attr_reader :filter_all_errors
|
44
|
+
|
36
45
|
alias_method :valgrind_generate_suppressions?, :valgrind_generate_suppressions
|
46
|
+
alias_method :filter_all_errors?, :filter_all_errors
|
37
47
|
|
38
48
|
def initialize(
|
39
49
|
binary_name:,
|
@@ -44,7 +54,8 @@ module RubyMemcheck
|
|
44
54
|
valgrind_generate_suppressions: false,
|
45
55
|
skipped_ruby_functions: DEFAULT_SKIPPED_RUBY_FUNCTIONS,
|
46
56
|
valgrind_xml_dir: Dir.mktmpdir,
|
47
|
-
output_io: $stderr
|
57
|
+
output_io: $stderr,
|
58
|
+
filter_all_errors: false
|
48
59
|
)
|
49
60
|
@binary_name = binary_name
|
50
61
|
@ruby = ruby
|
@@ -56,6 +67,7 @@ module RubyMemcheck
|
|
56
67
|
@valgrind_generate_suppressions = valgrind_generate_suppressions
|
57
68
|
@skipped_ruby_functions = skipped_ruby_functions
|
58
69
|
@output_io = output_io
|
70
|
+
@filter_all_errors = filter_all_errors
|
59
71
|
|
60
72
|
if valgrind_xml_dir
|
61
73
|
valgrind_xml_dir = File.expand_path(valgrind_xml_dir)
|
data/lib/ruby_memcheck/frame.rb
CHANGED
@@ -14,17 +14,18 @@ module RubyMemcheck
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def in_ruby?
|
17
|
+
return false unless obj
|
18
|
+
|
17
19
|
obj == configuration.ruby ||
|
18
20
|
# Hack to fix Ruby built with --enabled-shared
|
19
21
|
File.basename(obj) == "libruby.so.#{RUBY_VERSION}"
|
20
22
|
end
|
21
23
|
|
22
24
|
def in_binary?
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
25
|
+
return false unless obj
|
26
|
+
|
27
|
+
binary_name_without_ext = File.join(File.dirname(obj), File.basename(obj, ".*"))
|
28
|
+
binary_name_without_ext.end_with?(File.join("", configuration.binary_name))
|
28
29
|
end
|
29
30
|
|
30
31
|
def to_s
|
data/suppressions/ruby.supp
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_memcheck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Zhu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/ruby_memcheck/rspec/rake_task.rb
|
144
144
|
- lib/ruby_memcheck/stack.rb
|
145
145
|
- lib/ruby_memcheck/suppression.rb
|
146
|
+
- lib/ruby_memcheck/test_helper.rb
|
146
147
|
- lib/ruby_memcheck/test_task.rb
|
147
148
|
- lib/ruby_memcheck/test_task_reporter.rb
|
148
149
|
- lib/ruby_memcheck/valgrind_error.rb
|
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
170
|
- !ruby/object:Gem::Version
|
170
171
|
version: '0'
|
171
172
|
requirements: []
|
172
|
-
rubygems_version: 3.
|
173
|
+
rubygems_version: 3.4.1
|
173
174
|
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: Use Valgrind memcheck without going crazy
|