trace: disable tracing when owner disappears

* Disable trace source and release ownership on subject destruction.
* Note, since the policy module is also destroyed on descruction of the
  session component, the traced component must not access the policy
  module when acknowledging the disabled state (else: page fault).

Fixes genodelabs/genode#4247
This commit is contained in:
Johannes Schlatow 2021-08-12 16:07:13 +02:00 committed by Christian Helmuth
parent 81d939f947
commit 5e284bfb35
2 changed files with 13 additions and 6 deletions

View File

@ -189,6 +189,19 @@ class Genode::Trace::Subject
_label(label), _name(name)
{ }
/**
* Destructor, releases ownership of associated source
*/
~Subject()
{
Locked_ptr<Source> source(_source);
if (source.valid()) {
source->disable();
source->release_ownership(*this);
}
}
/**
* Return registry-local ID
*/

View File

@ -60,11 +60,6 @@ bool Trace::Logger::_evaluate_control()
/* unload policy */
if (policy_module) {
/* revoke relocations */
for (unsigned i = 0; i < sizeof(Trace::Policy_module)/sizeof(void *); i++) {
((addr_t *)policy_module)[i] -= (addr_t)(policy_module);
}
_env().rm().detach(policy_module);
policy_module = 0;
}
@ -81,7 +76,6 @@ bool Trace::Logger::_evaluate_control()
}
else if (control->to_be_enabled()) {
control->acknowledge_enabled();
enabled = true;
}