mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix ObjectSpace.trace_object_allocations_stop to not raise if the tracepoint were not initialized
This commit is contained in:
parent
7d01d8811b
commit
a74df67244
Notes:
git
2020-08-20 00:13:33 +09:00
2 changed files with 15 additions and 2 deletions
|
@ -290,9 +290,13 @@ trace_object_allocations_stop(VALUE self)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg->running == 0) {
|
if (arg->running == 0) {
|
||||||
|
if (arg->newobj_trace != 0) {
|
||||||
rb_tracepoint_disable(arg->newobj_trace);
|
rb_tracepoint_disable(arg->newobj_trace);
|
||||||
|
}
|
||||||
|
if (arg->freeobj_trace != 0) {
|
||||||
rb_tracepoint_disable(arg->freeobj_trace);
|
rb_tracepoint_disable(arg->freeobj_trace);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,15 @@ class TestObjSpace < Test::Unit::TestCase
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_trace_object_allocations_stop_first
|
||||||
|
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
|
begin;
|
||||||
|
require "objspace"
|
||||||
|
# Make sure stoping before the tracepoints are initialized doesn't raise. See [Bug #17020]
|
||||||
|
ObjectSpace.trace_object_allocations_stop
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
|
||||||
def test_trace_object_allocations
|
def test_trace_object_allocations
|
||||||
ObjectSpace.trace_object_allocations_clear # clear object_table to get rid of erroneous detection for c0
|
ObjectSpace.trace_object_allocations_clear # clear object_table to get rid of erroneous detection for c0
|
||||||
Class.name
|
Class.name
|
||||||
|
|
Loading…
Add table
Reference in a new issue