From d1c2e0baeba415190676f5ed6d1b75bc242a6166 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 8 Oct 2020 17:54:01 -0700 Subject: [PATCH] ircd::ctx: Belay marking entry point until after initial interrupt check. --- ircd/ctx.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 1a9341475..c928b52d7 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -150,10 +150,8 @@ noexcept try this->yc = &yc; notes = 1; stack.base = uintptr_t(__builtin_frame_address(0)); - mark(prof::event::ENTER); const unwind atexit{[this] { - mark(prof::event::LEAVE); adjoindre.notify_all(); stack.at = 0; notes = 0; @@ -166,6 +164,17 @@ noexcept try // Check for a precocious interrupt interruption_point(); + // Mark the point of context entry only after the interrupt check. If the + // context was interrupted without ever entering (which makes the above + // check throw) we never record any execution slice or increment the epoch + // counter for it. This can allow a parent context to assume application + // state remains unmodified by the aborted context. + mark(prof::event::ENTER); + const unwind leaver{[this] + { + mark(prof::event::LEAVE); + }}; + // Call the user's function. func();