mirror of
https://github.com/matrix-construct/construct
synced 2024-06-11 06:28:55 +02:00
ircd::ctx: Cleanup and recondition stack-protect related.
This commit is contained in:
parent
97880281f8
commit
48b50acab2
27
ircd/ctx.cc
27
ircd/ctx.cc
|
@ -13,6 +13,16 @@
|
|||
#include <ircd/asio.h>
|
||||
#include "ctx.h"
|
||||
|
||||
/// We make a special use of the stack-protector canary in certain places as
|
||||
/// another tool to detect corruption of a context's stack, specifically
|
||||
/// during yield and resume. This use is not really to provide security; just
|
||||
/// a kind of extra assertion, so we eliminate its emission during release.
|
||||
#ifndef NDEBUG
|
||||
#define IRCD_CTX_STACK_PROTECT __attribute__((stack_protect))
|
||||
#else
|
||||
#define IRCD_CTX_STACK_PROTECT
|
||||
#endif
|
||||
|
||||
/// Instance list linkage for the list of all ctx instances.
|
||||
template<>
|
||||
decltype(ircd::util::instance_list<ircd::ctx::ctx>::list)
|
||||
|
@ -36,9 +46,7 @@ ircd::ctx::ctx::id_ctr
|
|||
|
||||
/// Spawn (internal)
|
||||
void
|
||||
#ifdef IRCD_CTX_STACK_PROTECT
|
||||
__attribute__((stack_protect))
|
||||
#endif
|
||||
IRCD_CTX_STACK_PROTECT
|
||||
ircd::ctx::spawn(ctx *const c,
|
||||
context::function func)
|
||||
{
|
||||
|
@ -67,10 +75,7 @@ noexcept
|
|||
/// This function is the first thing executed on the new context's stack
|
||||
/// and calls the user's function.
|
||||
void
|
||||
#ifdef IRCD_CTX_STACK_PROTECT
|
||||
__attribute__((stack_protect))
|
||||
#endif
|
||||
__attribute__((noinline))
|
||||
IRCD_CTX_STACK_PROTECT
|
||||
ircd::ctx::ctx::operator()(boost::asio::yield_context yc,
|
||||
const std::function<void ()> func)
|
||||
noexcept try
|
||||
|
@ -128,9 +133,7 @@ catch(const std::exception &e)
|
|||
/// This currently doesn't work yet because the suspension state of this
|
||||
/// context has to be ready to be jumped to and that isn't implemented yet.
|
||||
void
|
||||
#ifdef IRCD_CTX_STACK_PROTECT_SWITCH
|
||||
__attribute__((stack_protect))
|
||||
#endif
|
||||
IRCD_CTX_STACK_PROTECT
|
||||
ircd::ctx::ctx::jump()
|
||||
{
|
||||
assert(this->yc);
|
||||
|
@ -159,9 +162,7 @@ ircd::ctx::ctx::jump()
|
|||
/// if the context suspended and was notified. When a context wakes up the
|
||||
/// note counter is reset.
|
||||
bool
|
||||
#ifdef IRCD_CTX_STACK_PROTECT_SWITCH
|
||||
__attribute__((stack_protect))
|
||||
#endif
|
||||
IRCD_CTX_STACK_PROTECT
|
||||
ircd::ctx::ctx::wait()
|
||||
{
|
||||
namespace errc = boost::system::errc;
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#if RB_OPTIMIZE_LEVEL != 3
|
||||
#define IRCD_CTX_STACK_PROTECT
|
||||
#define IRCD_CTX_STACK_PROTECT_SWITCH
|
||||
#endif
|
||||
|
||||
namespace ircd::ctx
|
||||
{
|
||||
struct stack;
|
||||
|
|
Loading…
Reference in a new issue