From b1a27b417b24f11735f188d69a680b7cb6c9d364 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Wed, 16 Aug 2017 14:14:07 +0200 Subject: [PATCH] core: fix deadlock in signal delivery Acquire Signal_context objects locks via Object_pool::apply() in the context of the entrpyoint thread, instead in the context of the calling thread. Fixes #2485 --- .../base/src/core/signal_transmitter_proxy.cc | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/repos/base/src/core/signal_transmitter_proxy.cc b/repos/base/src/core/signal_transmitter_proxy.cc index 476d082cd..d72655316 100644 --- a/repos/base/src/core/signal_transmitter_proxy.cc +++ b/repos/base/src/core/signal_transmitter_proxy.cc @@ -30,13 +30,7 @@ namespace { struct Signal_delivery_proxy { - /* - * Wrap pointer into struct to transmit it (core-locally) as plain-old - * data. - */ - struct Context_ptr { Signal_context_component *ptr; }; - - GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Context_ptr, unsigned); + GENODE_RPC(Rpc_deliver, void, _deliver_from_ep, Signal_context_capability, unsigned); GENODE_RPC_INTERFACE(Rpc_deliver); }; @@ -63,10 +57,14 @@ namespace { * can produce legitimate IPC reply messages to 'Signal_source' * clients. */ - void _deliver_from_ep(Context_ptr context_ptr, unsigned cnt) + void _deliver_from_ep(Signal_context_capability cap, unsigned cnt) { - Signal_context_component *context = context_ptr.ptr; - context->source()->submit(context, cnt); + _ep.apply(cap, [&] (Signal_context_component *context) { + if (context) + context->source()->submit(context, cnt); + else + warning("invalid signal-context capability"); + }); } /** @@ -77,17 +75,8 @@ namespace { * * Called from threads other than 'ep'. */ - void submit(Signal_context_capability cap, unsigned cnt) - { - _ep.apply(cap, [&] (Signal_context_component *context) { - - if (context) { - _proxy_cap.call(Context_ptr{context}, cnt); - } else { - warning("invalid signal-context capability"); - } - }); - } + void submit(Signal_context_capability cap, unsigned cnt) { + _proxy_cap.call(cap, cnt); } }; }