ruby_memcheck 2.0.0 → 2.1.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 +3 -3
- data/README.md +16 -6
- data/exe/ruby_memcheck +9 -0
- data/lib/ruby_memcheck/ruby_runner.rb +32 -0
- data/lib/ruby_memcheck/version.rb +1 -1
- data/lib/ruby_memcheck.rb +3 -0
- data/suppressions/ruby.supp +9 -7
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5d9a9370f2c62f82adb6bccb89e003e7fd42662a3ea786fc6625689e55e85f
|
4
|
+
data.tar.gz: dc82e568dc90d505363dae4f486c1b2f849141328d0a4326ae7a0d8bfe712739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0a004789b25d7407fd7ffcacdd3c155e73f1662f7fbeda7d8abc17b79d3dc24d5c7dafe95ee0b35cd48e860eec156293a5cdc1077f86148e979a6fab09144f
|
7
|
+
data.tar.gz: 06513eb0786d509df597c2efd929050669d8825bb09badd2d2f9d9ec9ee0df9bfa21ce43fbbc34f55d736b2c0eb0d497c96c658a5e7fe93a190633dcfb47bda8
|
data/.github/workflows/test.yml
CHANGED
@@ -23,9 +23,9 @@ jobs:
|
|
23
23
|
- run: sudo apt-get install -y libc6-dbg
|
24
24
|
- name: Install Valgrind from source
|
25
25
|
run: |
|
26
|
-
wget https://sourceware.org/pub/valgrind/valgrind-3.
|
27
|
-
tar xvf valgrind-3.
|
28
|
-
cd valgrind-3.
|
26
|
+
wget https://sourceware.org/pub/valgrind/valgrind-3.21.0.tar.bz2
|
27
|
+
tar xvf valgrind-3.21.0.tar.bz2
|
28
|
+
cd valgrind-3.21.0
|
29
29
|
./configure
|
30
30
|
make
|
31
31
|
sudo make install
|
data/README.md
CHANGED
@@ -9,7 +9,8 @@ This gem provides a sane way to use Valgrind's memcheck on your native extension
|
|
9
9
|
1. [How does it work?](#how-does-it-work)
|
10
10
|
1. [Limitations](#limitations)
|
11
11
|
1. [Installation](#installation)
|
12
|
-
1. [
|
12
|
+
1. [Running a Ruby script](#running-a-ruby-script)
|
13
|
+
1. [Setup for test suites](#setup-for-test-suites)
|
13
14
|
1. [Configuration](#configuration)
|
14
15
|
1. [Suppression files](#suppression-files)
|
15
16
|
1. [License](#license)
|
@@ -48,7 +49,16 @@ Because of the aggressive heuristics used to filter out false positives, there a
|
|
48
49
|
gem install ruby_memcheck
|
49
50
|
```
|
50
51
|
|
51
|
-
##
|
52
|
+
## Running a Ruby script
|
53
|
+
|
54
|
+
You can run a Ruby script under ruby_memcheck. This will report all memory leaks in all native extensions found in your Ruby script. Simply replace the `ruby` part of your command with `ruby_memcheck`. For example:
|
55
|
+
|
56
|
+
```sh
|
57
|
+
$ ruby_memcheck -e "puts 'Hello world'"
|
58
|
+
Hello world
|
59
|
+
```
|
60
|
+
|
61
|
+
## Setup for test suites
|
52
62
|
|
53
63
|
> **Note**
|
54
64
|
> If you encounter errors from Valgrind that looks like this:
|
@@ -61,15 +71,15 @@ gem install ruby_memcheck
|
|
61
71
|
> You can install Valgrind from source using the following commands:
|
62
72
|
> ```
|
63
73
|
> sudo apt-get install -y libc6-dbg
|
64
|
-
> wget https://sourceware.org/pub/valgrind/valgrind-3.
|
65
|
-
> tar xvf valgrind-3.
|
66
|
-
> cd valgrind-3.
|
74
|
+
> wget https://sourceware.org/pub/valgrind/valgrind-3.21.0.tar.bz2
|
75
|
+
> tar xvf valgrind-3.21.0.tar.bz2
|
76
|
+
> cd valgrind-3.21.0
|
67
77
|
> ./configure
|
68
78
|
> make
|
69
79
|
> sudo make install
|
70
80
|
> ```
|
71
81
|
|
72
|
-
|
82
|
+
You can use ruby_memcheck on your test suite (Minitest or RSpec) using rake.
|
73
83
|
|
74
84
|
0. Install Valgrind.
|
75
85
|
1. In your Rakefile, require this gem.
|
data/exe/ruby_memcheck
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyMemcheck
|
4
|
+
class RubyRunner
|
5
|
+
attr_reader :configuration
|
6
|
+
attr_reader :reporter
|
7
|
+
|
8
|
+
def initialize(*args)
|
9
|
+
@configuration =
|
10
|
+
if !args.empty? && args[0].is_a?(Configuration)
|
11
|
+
args.shift
|
12
|
+
else
|
13
|
+
RubyMemcheck.default_configuration
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(*args, **options)
|
18
|
+
command = configuration.command(args.map { |a| Shellwords.escape(a) })
|
19
|
+
|
20
|
+
@reporter = TestTaskReporter.new(configuration)
|
21
|
+
|
22
|
+
@reporter.setup
|
23
|
+
|
24
|
+
system(command, options)
|
25
|
+
exit_code = $CHILD_STATUS.exitstatus
|
26
|
+
|
27
|
+
@reporter.report_valgrind_errors
|
28
|
+
|
29
|
+
exit_code
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ruby_memcheck.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "English"
|
4
|
+
require "shellwords"
|
3
5
|
require "tempfile"
|
4
6
|
require "rake/testtask"
|
5
7
|
|
6
8
|
require "ruby_memcheck/configuration"
|
7
9
|
require "ruby_memcheck/frame"
|
10
|
+
require "ruby_memcheck/ruby_runner"
|
8
11
|
require "ruby_memcheck/stack"
|
9
12
|
require "ruby_memcheck/test_task_reporter"
|
10
13
|
require "ruby_memcheck/test_task"
|
data/suppressions/ruby.supp
CHANGED
@@ -12,13 +12,6 @@
|
|
12
12
|
fun:require_internal
|
13
13
|
...
|
14
14
|
}
|
15
|
-
{
|
16
|
-
Remove this after Ruby 2.7.7, 3.0.5, 3.1.3 are relased. See: https://github.com/Shopify/ruby_memcheck/issues/6
|
17
|
-
Memcheck:Leak
|
18
|
-
...
|
19
|
-
fun:stack_chunk_alloc
|
20
|
-
...
|
21
|
-
}
|
22
15
|
{
|
23
16
|
recursive_list_access creates a hash called `list` that is stored on the threadptr_recursive_hash. This is reported as a memory leak.
|
24
17
|
Memcheck:Leak
|
@@ -58,3 +51,12 @@
|
|
58
51
|
fun:strscan_do_scan
|
59
52
|
...
|
60
53
|
}
|
54
|
+
{
|
55
|
+
The callcache table (RCLASS_CC_TBL) is lazily created, so it is allocated when the first method that gets cached. If this happens in a native extension, it may be reported as a memory leak.
|
56
|
+
Memcheck:Leak
|
57
|
+
...
|
58
|
+
fun:rb_id_table_create
|
59
|
+
...
|
60
|
+
fun:rb_callable_method_entry
|
61
|
+
...
|
62
|
+
}
|
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: 2.
|
4
|
+
version: 2.1.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: 2023-08-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -125,7 +125,8 @@ dependencies:
|
|
125
125
|
description:
|
126
126
|
email:
|
127
127
|
- peter@peterzhu.ca
|
128
|
-
executables:
|
128
|
+
executables:
|
129
|
+
- ruby_memcheck
|
129
130
|
extensions: []
|
130
131
|
extra_rdoc_files: []
|
131
132
|
files:
|
@@ -138,10 +139,12 @@ files:
|
|
138
139
|
- LICENSE.txt
|
139
140
|
- README.md
|
140
141
|
- Rakefile
|
142
|
+
- exe/ruby_memcheck
|
141
143
|
- lib/ruby_memcheck.rb
|
142
144
|
- lib/ruby_memcheck/configuration.rb
|
143
145
|
- lib/ruby_memcheck/frame.rb
|
144
146
|
- lib/ruby_memcheck/rspec/rake_task.rb
|
147
|
+
- lib/ruby_memcheck/ruby_runner.rb
|
145
148
|
- lib/ruby_memcheck/stack.rb
|
146
149
|
- lib/ruby_memcheck/suppression.rb
|
147
150
|
- lib/ruby_memcheck/test_helper.rb
|