mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-29 13:44:26 +00:00
base: release signal context from signal list
Remove signal context object from signal source component list (_signal_queue) before destruction, otherwise we get a dangling pointer. On native hardware for base-nova, the signal source thread triggered page faults in the Signal_source_component::wait_for_signal() method when the signal context got freed up in Signal_session_component::free_context but was still enqueued in Signal_source_component::_signal_queue. Fixes #600
This commit is contained in:
parent
6fa57141ae
commit
e8c063a8b4
@ -32,6 +32,12 @@ using namespace Genode;
|
|||||||
** Signal-source component **
|
** Signal-source component **
|
||||||
*****************************/
|
*****************************/
|
||||||
|
|
||||||
|
void Signal_source_component::release(Signal_context_component *context)
|
||||||
|
{
|
||||||
|
if (context && context->is_enqueued())
|
||||||
|
_signal_queue.remove(context);
|
||||||
|
}
|
||||||
|
|
||||||
void Signal_source_component::submit(Signal_context_component *context,
|
void Signal_source_component::submit(Signal_context_component *context,
|
||||||
Ipc_ostream *ostream,
|
Ipc_ostream *ostream,
|
||||||
int cnt)
|
int cnt)
|
||||||
|
@ -30,6 +30,12 @@ using namespace Genode;
|
|||||||
** Signal-source component **
|
** Signal-source component **
|
||||||
*****************************/
|
*****************************/
|
||||||
|
|
||||||
|
void Signal_source_component::release(Signal_context_component *context)
|
||||||
|
{
|
||||||
|
if (context && context->is_enqueued())
|
||||||
|
_signal_queue.remove(context);
|
||||||
|
}
|
||||||
|
|
||||||
void Signal_source_component::submit(Signal_context_component *context,
|
void Signal_source_component::submit(Signal_context_component *context,
|
||||||
Ipc_ostream *ostream,
|
Ipc_ostream *ostream,
|
||||||
int cnt)
|
int cnt)
|
||||||
@ -41,8 +47,7 @@ void Signal_source_component::submit(Signal_context_component *context,
|
|||||||
_signal_queue.enqueue(context);
|
_signal_queue.enqueue(context);
|
||||||
|
|
||||||
/* wake up client */
|
/* wake up client */
|
||||||
Nova::sm_ctrl(_blocking_semaphore.local_name(),
|
Nova::sm_ctrl(_blocking_semaphore.local_name(), Nova::SEMAPHORE_UP);
|
||||||
Nova::SEMAPHORE_UP);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +72,7 @@ Signal_source_component::Signal_source_component(Rpc_entrypoint *ep)
|
|||||||
{
|
{
|
||||||
/* initialized blocking semaphore */
|
/* initialized blocking semaphore */
|
||||||
addr_t sem_sel = cap_selector_allocator()->alloc();
|
addr_t sem_sel = cap_selector_allocator()->alloc();
|
||||||
uint8_t ret = Nova::create_sm(sem_sel,
|
uint8_t ret = Nova::create_sm(sem_sel, Platform_pd::pd_core_sel(), 0);
|
||||||
Platform_pd::pd_core_sel(), 0);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
PERR("create_sm returned %u", ret);
|
PERR("create_sm returned %u", ret);
|
||||||
|
|
||||||
|
@ -48,6 +48,11 @@ namespace Genode {
|
|||||||
Signal_context_component(long imprint, Signal_source_component *source)
|
Signal_context_component(long imprint, Signal_source_component *source)
|
||||||
: _imprint(imprint), _cnt(0), _source(source) { }
|
: _imprint(imprint), _cnt(0), _source(source) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* De-constructor
|
||||||
|
*/
|
||||||
|
~Signal_context_component();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Increment number of signals to be delivered at once
|
* Increment number of signals to be delivered at once
|
||||||
*/
|
*/
|
||||||
@ -79,6 +84,8 @@ namespace Genode {
|
|||||||
*/
|
*/
|
||||||
Signal_source_component(Rpc_entrypoint *rpc_entrypoint);
|
Signal_source_component(Rpc_entrypoint *rpc_entrypoint);
|
||||||
|
|
||||||
|
void release(Signal_context_component *context);
|
||||||
|
|
||||||
void submit(Signal_context_component *context,
|
void submit(Signal_context_component *context,
|
||||||
Ipc_ostream *ostream,
|
Ipc_ostream *ostream,
|
||||||
int cnt);
|
int cnt);
|
||||||
|
@ -40,12 +40,13 @@ Signal_session_component::Signal_session_component(Rpc_entrypoint *source_ep,
|
|||||||
|
|
||||||
Signal_session_component::~Signal_session_component()
|
Signal_session_component::~Signal_session_component()
|
||||||
{
|
{
|
||||||
|
/* remove _signal_source from entrypoint */
|
||||||
|
_source_ep->dissolve(&_source);
|
||||||
|
|
||||||
/* free all signal contexts */
|
/* free all signal contexts */
|
||||||
while (Signal_context_component *r = _contexts_slab.first_object())
|
while (Signal_context_component *r = _contexts_slab.first_object())
|
||||||
free_context(r->cap());
|
free_context(r->cap());
|
||||||
|
|
||||||
/* remove _signal_source from entrypoint */
|
|
||||||
_source_ep->dissolve(&_source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -99,3 +100,8 @@ void Signal_session_component::submit(Signal_context_capability context_cap,
|
|||||||
|
|
||||||
context->source()->submit(context, _ipc_ostream, cnt);
|
context->source()->submit(context, _ipc_ostream, cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Signal_context_component::~Signal_context_component() {
|
||||||
|
if (is_enqueued() && _source)
|
||||||
|
_source->release(this);
|
||||||
|
}
|
||||||
|
@ -25,6 +25,12 @@ using namespace Genode;
|
|||||||
** Signal-source component **
|
** Signal-source component **
|
||||||
*****************************/
|
*****************************/
|
||||||
|
|
||||||
|
void Signal_source_component::release(Signal_context_component *context)
|
||||||
|
{
|
||||||
|
if (context && context->is_enqueued())
|
||||||
|
_signal_queue.remove(context);
|
||||||
|
}
|
||||||
|
|
||||||
void Signal_source_component::submit(Signal_context_component *context,
|
void Signal_source_component::submit(Signal_context_component *context,
|
||||||
Ipc_ostream *ostream,
|
Ipc_ostream *ostream,
|
||||||
int cnt)
|
int cnt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user