Fiasco.OC: check for leaks while thread creation

When unmarshalling capabilities it is checked, whether a capability with the
id was leaking, but this isn't done when creating a thread. Here the capability
is transfered indirectly via the thread state object. This patch checks for
old leakage capabilities while thread creation.
This commit is contained in:
Stefan Kalkowski 2012-05-03 15:37:29 +02:00 committed by Norman Feske
parent ac1ff2f5f8
commit c3fcd834b0
1 changed files with 9 additions and 0 deletions

View File

@ -61,6 +61,15 @@ void Thread_base::start()
l4_utcb_tcr_u(state.utcb)->user[UTCB_TCR_BADGE] = state.id;
l4_utcb_tcr_u(state.utcb)->user[UTCB_TCR_THREAD_OBJ] = (addr_t)this;
/* there might be leaks in the application */
Cap_index *idx = cap_map()->find(state.id);
if (idx) {
idx->inc();
PWRN("leaking capability idx=%p id=%x ref_cnt=%d",
idx, idx->id(), idx->dec());
cap_map()->remove(idx);
}
/* we need to manually increase the reference counter here */
cap_map()->insert(state.id, state.kcap)->inc();
} catch(Cap_index_allocator::Region_conflict) {