stackprof 0.2.23 → 0.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db2506be248e74ed4aefacbb3b7adc4936c88b1acb3517fde5510a225704b6bf
4
- data.tar.gz: 55aaefff3de2d6887cb9a861eb615faa85e48411eeadf778990bc1439e7c456e
3
+ metadata.gz: b299eb696cf0c2748e931532afab3f90bab1c94447ff1c844bce0eda878a93c6
4
+ data.tar.gz: bd2c389baa8253fc06beda425abc87762b9bca425c6bc5046655610fb9852e79
5
5
  SHA512:
6
- metadata.gz: e761d5f7da7687ecb51ecc493c3dc4ff8e86798b57cd65c429b90e29e4021827df58525b5ddd2d21d597cba4a31e251909daa33d518157d63c53e74944784fde
7
- data.tar.gz: a8c9da37e92aa2bcc64b2532367f749e5568cfa4e02758dca80d3d3f1b4f399b860dd215f880cea814356d50766103dc684f0192a04660075b5be6e43a7db121
6
+ metadata.gz: 322e506fc77bd964f39e7b3f0c5584e57efdec8e1dcc432cdea924536e334234d916a1d5e1ff085e2e5210a49751897ca36a4b1bd007468a5b16184151129be3
7
+ data.tar.gz: 3234d4159c78119a9238200d1f4516280cbd1e0cfe3affca1c4fa4827b805ecf154e38857c917fafe7aed042d67525bb7e6c5fce85a039e30cde4672ae08f97e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.25
2
+
3
+ * Fix GC marking
4
+
1
5
  # 0.2.16
2
6
 
3
7
  * [flamegraph.pl] Update to latest version
data/bin/stackprof CHANGED
@@ -2,13 +2,15 @@
2
2
  require 'optparse'
3
3
  require 'stackprof'
4
4
 
5
+ banner = <<-END
6
+ Usage: stackprof run [--mode=MODE|--out=FILE|--interval=INTERVAL|--format=FORMAT] -- COMMAND
7
+ Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]
8
+ END
9
+
5
10
  if ARGV.first == "run"
6
11
  ARGV.shift
7
12
  env = {}
8
- parser = OptionParser.new(ARGV) do |o|
9
- o.banner = "Usage: stackprof run [--mode=MODE|--out=FILE|--interval=INTERVAL|--format=FORMAT] -- COMMAND"
10
- o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]"
11
-
13
+ parser = OptionParser.new(banner) do |o|
12
14
  o.on('--mode [MODE]', String, 'Mode of sampling: cpu, wall, object, default to wall') do |mode|
13
15
  env["STACKPROF_MODE"] = mode
14
16
  end
@@ -37,10 +39,7 @@ if ARGV.first == "run"
37
39
  else
38
40
  options = {}
39
41
 
40
- parser = OptionParser.new(ARGV) do |o|
41
- o.banner = "Usage: stackprof run [--mode|--out|--interval] -- COMMAND"
42
- o.banner = "Usage: stackprof [file.dump]+ [--text|--method=NAME|--callgrind|--graphviz]"
43
-
42
+ parser = OptionParser.new(banner) do |o|
44
43
  o.on('--text', 'Text summary per method (default)'){ options[:format] = :text }
45
44
  o.on('--json', 'JSON output (use with web viewers)'){ options[:format] = :json }
46
45
  o.on('--files', 'List of files'){ |f| options[:format] = :files }
@@ -12,6 +12,7 @@
12
12
  #include <ruby/st.h>
13
13
  #include <ruby/io.h>
14
14
  #include <ruby/intern.h>
15
+ #include <ruby/vm.h>
15
16
  #include <signal.h>
16
17
  #include <sys/time.h>
17
18
  #include <time.h>
@@ -32,6 +33,7 @@ static const char *fake_frame_cstrs[] = {
32
33
  };
33
34
 
34
35
  static int stackprof_use_postponed_job = 1;
36
+ static int ruby_vm_running = 0;
35
37
 
36
38
  #define TOTAL_FAKE_FRAMES (sizeof(fake_frame_cstrs) / sizeof(char *))
37
39
 
@@ -725,6 +727,11 @@ stackprof_signal_handler(int sig, siginfo_t *sinfo, void *ucontext)
725
727
 
726
728
  if (!_stackprof.running) return;
727
729
 
730
+ // There's a possibility that the signal handler is invoked *after* the Ruby
731
+ // VM has been shut down (e.g. after ruby_cleanup(0)). In this case, things
732
+ // that rely on global VM state (e.g. rb_during_gc) will segfault.
733
+ if (!ruby_vm_running) return;
734
+
728
735
  if (_stackprof.mode == sym_wall) {
729
736
  // In "wall" mode, the SIGALRM signal will arrive at an arbitrary thread.
730
737
  // In order to provide more useful results, especially under threaded web
@@ -804,6 +811,10 @@ stackprof_gc_mark(void *data)
804
811
 
805
812
  if (_stackprof.frames)
806
813
  st_foreach(_stackprof.frames, frame_mark_i, 0);
814
+
815
+ for (int i = 0; i < _stackprof.buffer_count; i++) {
816
+ rb_gc_mark(_stackprof.frames_buffer[i]);
817
+ }
807
818
  }
808
819
 
809
820
  static void
@@ -845,6 +856,12 @@ stackprof_use_postponed_job_l(VALUE self)
845
856
  return Qnil;
846
857
  }
847
858
 
859
+ static void
860
+ stackprof_at_exit(ruby_vm_t* vm)
861
+ {
862
+ ruby_vm_running = 0;
863
+ }
864
+
848
865
  void
849
866
  Init_stackprof(void)
850
867
  {
@@ -855,6 +872,9 @@ Init_stackprof(void)
855
872
  */
856
873
  stackprof_use_postponed_job = RUBY_API_VERSION_MAJOR < 3;
857
874
 
875
+ ruby_vm_running = 1;
876
+ ruby_vm_at_exit(stackprof_at_exit);
877
+
858
878
  #define S(name) sym_##name = ID2SYM(rb_intern(#name));
859
879
  S(object);
860
880
  S(custom);
data/lib/stackprof.rb CHANGED
@@ -6,10 +6,15 @@ end
6
6
 
7
7
  if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?
8
8
  StackProf.use_postponed_job!
9
+ elsif RUBY_VERSION == "3.2.0"
10
+ # 3.2.0 crash is the signal is received at the wrong time.
11
+ # Fixed in https://github.com/ruby/ruby/pull/7116
12
+ # The fix is backported in 3.2.1: https://bugs.ruby-lang.org/issues/19336
13
+ StackProf.use_postponed_job!
9
14
  end
10
15
 
11
16
  module StackProf
12
- VERSION = '0.2.23'
17
+ VERSION = '0.2.25'
13
18
  end
14
19
 
15
20
  StackProf.autoload :Report, "stackprof/report.rb"
data/stackprof.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'stackprof'
3
- s.version = '0.2.23'
3
+ s.version = '0.2.25'
4
4
  s.homepage = 'http://github.com/tmm1/stackprof'
5
5
 
6
6
  s.authors = 'Aman Gupta'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackprof
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.23
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aman Gupta
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-29 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -99,10 +99,10 @@ licenses:
99
99
  - MIT
100
100
  metadata:
101
101
  bug_tracker_uri: https://github.com/tmm1/stackprof/issues
102
- changelog_uri: https://github.com/tmm1/stackprof/blob/v0.2.23/CHANGELOG.md
103
- documentation_uri: https://www.rubydoc.info/gems/stackprof/0.2.23
104
- source_code_uri: https://github.com/tmm1/stackprof/tree/v0.2.23
105
- post_install_message:
102
+ changelog_uri: https://github.com/tmm1/stackprof/blob/v0.2.25/CHANGELOG.md
103
+ documentation_uri: https://www.rubydoc.info/gems/stackprof/0.2.25
104
+ source_code_uri: https://github.com/tmm1/stackprof/tree/v0.2.25
105
+ post_install_message:
106
106
  rdoc_options: []
107
107
  require_paths:
108
108
  - lib
@@ -117,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.3.23
121
- signing_key:
120
+ rubygems_version: 3.0.3.1
121
+ signing_key:
122
122
  specification_version: 4
123
123
  summary: sampling callstack-profiler for ruby 2.2+
124
124
  test_files: []