From 0219f6fc3b16925aee5dad7b5e83ea49e8f64974 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 26 Dec 2022 05:14:37 +0000 Subject: [PATCH] Call abort() when double free occurs When double free occurs, rpc-port library calls abort(). This is for deubgging C# applications. Change-Id: I15465d756f8b17d21b4b56bb2938cb2c8b536fe4 Signed-off-by: Hwankyu Jhun --- src/rpc-port.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rpc-port.cc b/src/rpc-port.cc index 6d38540..88799b0 100644 --- a/src/rpc-port.cc +++ b/src/rpc-port.cc @@ -297,6 +297,11 @@ RPC_API int rpc_port_proxy_destroy(rpc_port_proxy_h h) { auto p = static_cast*>(h); auto* proxy = p->get(); + if (proxy->IsDestroying()) { + _E("already destroyed. handle(%p)", proxy); + abort(); + } + _W("rpc_port_proxy_destroy(%p)", proxy); if (getpid() == gettid()) { delete p; @@ -434,6 +439,12 @@ RPC_API int rpc_port_stub_destroy(rpc_port_stub_h h) { _W("rpc_port_stub_destroy(%p)", h); auto p = static_cast<::StubExt*>(h); + if (p->IsDestroying()) { + _E("already destroyed. handle(%p)", h); + abort(); + } + + p->SetDestroying(true); aul_rpc_port_usr_destroy(p->GetPortName().c_str(), rpc_port_get_target_uid()); if (getpid() == gettid()) { delete p; @@ -441,7 +452,6 @@ RPC_API int rpc_port_stub_destroy(rpc_port_stub_h h) { } p->Ignore(); - p->SetDestroying(true); g_idle_add_full(G_PRIORITY_HIGH, [](gpointer data) -> gboolean { auto p = static_cast<::StubExt*>(data); -- 2.7.4