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:
Alexander Boettcher 2013-01-08 14:27:48 +01:00 committed by Norman Feske
parent 6fa57141ae
commit e8c063a8b4
5 changed files with 35 additions and 6 deletions

View File

@ -32,6 +32,12 @@ using namespace Genode;
** 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,
Ipc_ostream *ostream,
int cnt)

View File

@ -30,6 +30,12 @@ using namespace Genode;
** 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,
Ipc_ostream *ostream,
int cnt)
@ -41,8 +47,7 @@ void Signal_source_component::submit(Signal_context_component *context,
_signal_queue.enqueue(context);
/* wake up client */
Nova::sm_ctrl(_blocking_semaphore.local_name(),
Nova::SEMAPHORE_UP);
Nova::sm_ctrl(_blocking_semaphore.local_name(), Nova::SEMAPHORE_UP);
}
}
@ -67,8 +72,7 @@ Signal_source_component::Signal_source_component(Rpc_entrypoint *ep)
{
/* initialized blocking semaphore */
addr_t sem_sel = cap_selector_allocator()->alloc();
uint8_t ret = Nova::create_sm(sem_sel,
Platform_pd::pd_core_sel(), 0);
uint8_t ret = Nova::create_sm(sem_sel, Platform_pd::pd_core_sel(), 0);
if (ret)
PERR("create_sm returned %u", ret);

View File

@ -48,6 +48,11 @@ namespace Genode {
Signal_context_component(long imprint, Signal_source_component *source)
: _imprint(imprint), _cnt(0), _source(source) { }
/**
* De-constructor
*/
~Signal_context_component();
/**
* Increment number of signals to be delivered at once
*/
@ -79,6 +84,8 @@ namespace Genode {
*/
Signal_source_component(Rpc_entrypoint *rpc_entrypoint);
void release(Signal_context_component *context);
void submit(Signal_context_component *context,
Ipc_ostream *ostream,
int cnt);

View File

@ -40,12 +40,13 @@ Signal_session_component::Signal_session_component(Rpc_entrypoint *source_ep,
Signal_session_component::~Signal_session_component()
{
/* remove _signal_source from entrypoint */
_source_ep->dissolve(&_source);
/* free all signal contexts */
while (Signal_context_component *r = _contexts_slab.first_object())
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);
}
Signal_context_component::~Signal_context_component() {
if (is_enqueued() && _source)
_source->release(this);
}

View File

@ -25,6 +25,12 @@ using namespace Genode;
** 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,
Ipc_ostream *ostream,
int cnt)