Skip to content

Commit 578964b

Browse files
committed
hmon: fix segfault in heartbeat monitor interface
Fix segfault in the heartbeat monitor interface.
1 parent 8eeadfc commit 578964b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/health_monitoring_lib/cpp/tests/health_monitor_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ TEST_F(HealthMonitorTest, TestName)
7373
// Start HMON.
7474
hm.start();
7575

76+
heartbeat_monitor.heartbeat();
77+
7678
auto deadline_res = deadline_mon.get_deadline(IdentTag("deadline_1"));
7779

7880
{

src/health_monitoring_lib/rust/heartbeat/ffi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// SPDX-License-Identifier: Apache-2.0
1212
// *******************************************************************************
1313

14-
use crate::common::ffi::FFIHandle;
14+
use crate::common::ffi::{FFIBorrowed, FFIHandle};
1515
use crate::heartbeat::{HeartbeatMonitor, HeartbeatMonitorBuilder};
1616
use crate::TimeRange;
1717
use core::time::Duration;
@@ -57,7 +57,7 @@ pub extern "C" fn heartbeat_monitor_heartbeat(monitor_handle: FFIHandle) {
5757
// SAFETY:
5858
// Validity of the pointer is ensured.
5959
// It is assumed that the pointer was created by a call to `health_monitor_get_heartbeat_monitor`.
60-
let monitor = unsafe { Box::from_raw(monitor_handle as *mut HeartbeatMonitor) };
60+
let monitor = FFIBorrowed::new(unsafe { Box::from_raw(monitor_handle as *mut HeartbeatMonitor) });
6161

6262
monitor.heartbeat();
6363
}

0 commit comments

Comments
 (0)