diff --git a/bindings/cpu_profiler.cc b/bindings/cpu_profiler.cc index 68b48961..f4bdb6d0 100644 --- a/bindings/cpu_profiler.cc +++ b/bindings/cpu_profiler.cc @@ -108,7 +108,13 @@ class MeasurementsTicker { ~MeasurementsTicker() { uv_timer_stop(&timer); - uv_close(reinterpret_cast(&timer), nullptr); + + auto handle = reinterpret_cast(&timer); + + // Calling uv_close on an inactive handle will cause a segfault. + if (uv_is_active(handle)) { + uv_close(handle, nullptr); + } } };