[lttng-dev] Bulletproof RCU arena resize bug

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Mon Sep 30 11:49:11 EDT 2013


----- Original Message -----
> From: "Milosz Tanski" <milosz at adfin.com>
> To: lttng-dev at lists.lttng.org
> Sent: Monday, September 30, 2013 11:16:37 AM
> Subject: [lttng-dev] Bulletproof RCU arena resize bug
> 
> Hi,
> 
> While trying to use the BP flavor of RCU I ran into random crashes. I
> tracked it down to issues with resizing of the BP RCU memory pool.
> 
> The problem is in the urcu-bp.c file in the resize_arena() function.
> On successful allocation / remapping the len member of the
> registry_arena struct is never set anywhere function. On the second
> resize of the arena the code in resize_arena() still thinks the
> previous size is equal to the original mapping size. I've fixed this
> issue locally by just adding the following code at the bottom of
> resize_arena().
> 
> I hope this helps,

Good catch !!

However, I think your fix misses one case: if we happen to re-use the same region, we want to update the length right ? I propose:

diff --git a/urcu-bp.c b/urcu-bp.c
index a823659..34bd14e 100644
--- a/urcu-bp.c
+++ b/urcu-bp.c
@@ -316,6 +316,7 @@ static void resize_arena(struct registry_arena *arena, size_t len)
                new_arena = mremap_wrapper(arena->p, arena->len,
                                        len, MREMAP_MAYMOVE);
        assert(new_arena != MAP_FAILED);
+       arena->len = len;

        /*
         * re-used the same region ?

(sorry for bad patch formatting, I'm currently updating my mail client setup)

Thoughts ?

Thanks,

Mathieu



> - Milosz
> 
> diff --git a/urcu-bp.c b/urcu-bp.c
> index a823659..d26dcc7 100644
> --- a/urcu-bp.c
> +++ b/urcu-bp.c
> @@ -325,6 +329,7 @@ static void resize_arena(struct registry_arena
> *arena, size_t len)
> 
>         bzero(new_arena + arena->len, len - arena->len);
>         arena->p = new_arena;
> +       arena->len = len;
>  }
> 
>  /* Called with signals off and mutex locked */
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list