diff --git a/ext/fiber/profiler/capture.c b/ext/fiber/profiler/capture.c index bbd418b..189ae50 100644 --- a/ext/fiber/profiler/capture.c +++ b/ext/fiber/profiler/capture.c @@ -140,6 +140,7 @@ void Fiber_Profiler_Capture_Call_initialize(void *element) { call->event_flag = 0; call->id = 0; + call->klass = Qnil; call->path = NULL; call->line = 0; diff --git a/test/fiber/profiler/capture.rb b/test/fiber/profiler/capture.rb index 1fb915d..0696711 100644 --- a/test/fiber/profiler/capture.rb +++ b/test/fiber/profiler/capture.rb @@ -185,6 +185,28 @@ def nested(n = 100, &block) end end + with "blocks outside of methods" do + # Blocks defined outside of a method don't have a method or class: + work = proc do + String.new + [1, 2].each{sleep 0.001} + end + + it "doesn't report a class left over from an earlier call" do + capture.start + + Fiber.new(&work).resume + + capture.stop + + stall = JSON.parse(output.string) + classes = stall["calls"].map{|call| call["class"]} + + expect(classes).not.to have_value(be == "String") + expect(classes).not.to have_value(be == "false") + end + end + with "Process.fork" do it "should disable the profiler in the child process after fork" do capture.start