зеркало из https://github.com/github/ruby.git
Fix ObjectSpace.trace_object_allocations_stop to not raise if the tracepoint were not initialized
This commit is contained in:
Родитель
7d01d8811b
Коммит
a74df67244
|
@ -290,8 +290,12 @@ trace_object_allocations_stop(VALUE self)
|
|||
}
|
||||
|
||||
if (arg->running == 0) {
|
||||
rb_tracepoint_disable(arg->newobj_trace);
|
||||
rb_tracepoint_disable(arg->freeobj_trace);
|
||||
if (arg->newobj_trace != 0) {
|
||||
rb_tracepoint_disable(arg->newobj_trace);
|
||||
}
|
||||
if (arg->freeobj_trace != 0) {
|
||||
rb_tracepoint_disable(arg->freeobj_trace);
|
||||
}
|
||||
}
|
||||
|
||||
return Qnil;
|
||||
|
|
|
@ -164,6 +164,15 @@ class TestObjSpace < Test::Unit::TestCase
|
|||
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
|
||||
ObjectSpace.trace_object_allocations_clear # clear object_table to get rid of erroneous detection for c0
|
||||
Class.name
|
||||
|
|
Загрузка…
Ссылка в новой задаче