ruby_memcheck 1.2.0 → 1.3.1
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 +27 -2
- data/lib/ruby_memcheck/configuration.rb +15 -3
- data/lib/ruby_memcheck/frame.rb +6 -5
- data/lib/ruby_memcheck/valgrind_error.rb +1 -1
- data/lib/ruby_memcheck/version.rb +1 -1
- data/suppressions/ruby.supp +22 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7a2965241d52c1a38ece5788f2e029a6424fbd34f0b18ffc3dcc35253a45377
|
4
|
+
data.tar.gz: 4949a4a3357647895f61bc85353342a6257b329d970f854ca7105fd85843b4b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdc2918a24c74f5b238bc67a86d071006abc24df8a8ac613c5d555ad8de8c27a147c63bb85f42cfa6c13f1a14c3599c61329e93d324da741f5373d562d602a3a
|
7
|
+
data.tar.gz: b2f8a27e88f0ab7347429eda0fc484ffba7eecf01b29e7411a6d1cdafb7fac31dfed10d826ae5259b089102cd984c93f94196e346851b8b0aab2842dc02b7821
|
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.
|
@@ -73,7 +92,7 @@ The easiest way to use this gem is to use it on your test suite (minitest or RSp
|
|
73
92
|
|
74
93
|
1. Setup the test task for your test framework.
|
75
94
|
- **minitest**
|
76
|
-
|
95
|
+
|
77
96
|
Locate your test task(s) in your Rakefile. You can identify it with a call to `Rake::TestTask.new`.
|
78
97
|
|
79
98
|
Create a namespace under the test task and create a `RubyMemcheck::TestTask` with the same configuration.
|
@@ -139,6 +158,7 @@ When you run `RubyMemcheck.config`, you are creating a default `RubyMemcheck::Co
|
|
139
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.
|
140
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.
|
141
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`.
|
142
162
|
|
143
163
|
## Suppression files
|
144
164
|
|
@@ -155,7 +175,7 @@ Let's celebrate wins from this gem! If this gem was useful for you, please share
|
|
155
175
|
- Running on CI: [#162](https://github.com/Shopify/liquid-c/pull/162)
|
156
176
|
- [`nokogiri`](https://github.com/sparklemotion/nokogiri):
|
157
177
|
- Found 5 memory leaks: [4 in #2345](https://github.com/sparklemotion/nokogiri/pull/2345), [#2347](https://github.com/sparklemotion/nokogiri/pull/2347)
|
158
|
-
-
|
178
|
+
- Running on CI: [#2344](https://github.com/sparklemotion/nokogiri/pull/2344)
|
159
179
|
- [`rotoscope`](https://github.com/Shopify/rotoscope):
|
160
180
|
- Found a [memory leak in Ruby TracePoint](https://bugs.ruby-lang.org/issues/18264)
|
161
181
|
- Running on CI: [#89](https://github.com/Shopify/rotoscope/pull/89)
|
@@ -163,6 +183,11 @@ Let's celebrate wins from this gem! If this gem was useful for you, please share
|
|
163
183
|
- Found 1 memory leak: [#9150](https://github.com/protocolbuffers/protobuf/pull/9150)
|
164
184
|
- [`gRPC`](https://github.com/grpc/grpc):
|
165
185
|
- Found 1 memory leak: [#27900](https://github.com/grpc/grpc/pull/27900)
|
186
|
+
- [`wasmtime-rb`](https://github.com/bytecodealliance/wasmtime-rb):
|
187
|
+
- Found 1 memory leak: [#26](https://github.com/bytecodealliance/wasmtime-rb/pull/26)
|
188
|
+
- [`yarp`](https://github.com/shopify/yarp):
|
189
|
+
- Found 6 memory leaks and 1 memory error: [#292](https://github.com/Shopify/yarp/pull/304), [#292](https://github.com/Shopify/yarp/pull/292)
|
190
|
+
- Running on CI: [#293](https://github.com/Shopify/yarp/pull/293)
|
166
191
|
|
167
192
|
## License
|
168
193
|
|
@@ -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
@@ -28,3 +28,25 @@
|
|
28
28
|
fun:exec_recursive
|
29
29
|
...
|
30
30
|
}
|
31
|
+
{
|
32
|
+
"Invalid read of size 8" when marking the stack of fibers
|
33
|
+
Memcheck:Addr8
|
34
|
+
fun:each_location*
|
35
|
+
...
|
36
|
+
}
|
37
|
+
{
|
38
|
+
Rust probes for statx(buf), will be fixed in Valgrind >= 3.1.6.0
|
39
|
+
Memcheck:Param
|
40
|
+
statx(buf)
|
41
|
+
...
|
42
|
+
fun:*try_statx*
|
43
|
+
...
|
44
|
+
}
|
45
|
+
{
|
46
|
+
Rust probes for statx(file_name), will be fixed in Valgrind >= 3.1.6.0
|
47
|
+
Memcheck:Param
|
48
|
+
statx(file_name)
|
49
|
+
...
|
50
|
+
fun:*try_statx*
|
51
|
+
...
|
52
|
+
}
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Zhu
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '2.3'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- peter@peterzhu.ca
|
128
128
|
executables: []
|
@@ -155,7 +155,7 @@ licenses:
|
|
155
155
|
- MIT
|
156
156
|
metadata:
|
157
157
|
homepage_uri: https://github.com/peterzhu2118/ruby_memcheck
|
158
|
-
post_install_message:
|
158
|
+
post_install_message:
|
159
159
|
rdoc_options: []
|
160
160
|
require_paths:
|
161
161
|
- lib
|
@@ -170,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.
|
174
|
-
signing_key:
|
173
|
+
rubygems_version: 3.4.10
|
174
|
+
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Use Valgrind memcheck without going crazy
|
177
177
|
test_files: []
|