Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Cyrill Gorcunov <gorcunov@gmail.com>,
	tml <tarantool-patches@dev.tarantool.org>
Subject: Re: [Tarantool-patches] [PATCH v6 2/2] fiber: leak slab if unable to bring prots back
Date: Thu, 13 Feb 2020 01:08:45 +0100	[thread overview]
Message-ID: <90607bfb-8f31-765f-ae8d-7cdb34598b0c@tarantool.org> (raw)
In-Reply-To: <20200206123114.8010-3-gorcunov@gmail.com>

Thanks for the patch!

On 06/02/2020 13:31, Cyrill Gorcunov wrote:
> In case if we unable to revert guard page back to
> read|write we should never use such slab again.
> 
> Initially I thought of just put panic here and
> exit but it is too destructive. I think better
> print an error and continue. If node admin ignore
> this message then one moment at future there won't
> be slab left for use and creating new fibers get
> prohibited.
> 
> In future (hopefully near one) we plan to drop
> guard pages to prevent VMA fracturing and use
> stack marks instead.
> 
> Reviewed-by: Alexander Turenko <alexander.turenko@tarantool.org>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
>  src/lib/core/fiber.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
> index 57e4cb6ef..a501d846a 100644
> --- a/src/lib/core/fiber.c
> +++ b/src/lib/core/fiber.c
> @@ -1055,15 +1055,22 @@ fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc)
>  			 * to setup the original protection back in
>  			 * background.
>  			 *
> +			 * For now lets keep such slab referenced and
> +			 * leaked: if mprotect failed we must not allow
> +			 * to reuse such slab with PROT_NONE'ed page
> +			 * inside.
> +			 *
>  			 * Note that in case if we're called from
>  			 * fiber_stack_create() the @mprotect_flags is
>  			 * the same as the slab been created with, so
>  			 * calling mprotect for VMA with same flags
>  			 * won't fail.
>  			 */
> -			diag_log();
> +			say_syserror("fiber: Can't put guard page to slab. "
> +				     "Leak %zu bytes", (size_t)fiber->stack_size);

This behaviour actually should be testable, no? You could not test
diag, but you should be able to detect a leak. Using slab_cache_used(),
for example. Before and after a test.

> +		} else {
> +			slab_put(slabc, fiber->stack_slab);
>  		}
> -		slab_put(slabc, fiber->stack_slab);
>  	}
>  }

  reply	other threads:[~2020-02-13  0:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 12:31 [Tarantool-patches] [PATCH v6 0/2] fiber: Handle stack madvise/mprotect errors Cyrill Gorcunov
2020-02-06 12:31 ` [Tarantool-patches] [PATCH v6 1/2] fiber: set diagnostics at madvise/mprotect failure Cyrill Gorcunov
2020-02-13  0:08   ` Vladislav Shpilevoy
2020-02-13  8:19     ` Cyrill Gorcunov
2020-02-13 23:26       ` Vladislav Shpilevoy
2020-02-14  7:56         ` Cyrill Gorcunov
2020-02-06 12:31 ` [Tarantool-patches] [PATCH v6 2/2] fiber: leak slab if unable to bring prots back Cyrill Gorcunov
2020-02-13  0:08   ` Vladislav Shpilevoy [this message]
2020-02-13  8:20     ` Cyrill Gorcunov
2020-02-09 17:39 ` [Tarantool-patches] [PATCH v6 0/2] fiber: Handle stack madvise/mprotect errors Vladislav Shpilevoy
2020-02-09 18:34   ` Cyrill Gorcunov
2020-02-13  0:07 ` Vladislav Shpilevoy
2020-02-13  7:16   ` Cyrill Gorcunov
2020-02-20 19:25 ` Alexander Turenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=90607bfb-8f31-765f-ae8d-7cdb34598b0c@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v6 2/2] fiber: leak slab if unable to bring prots back' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox