[Tarantool-patches] [PATCH] box/error: ref error.prev while accessing it

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Apr 16 03:19:01 MSK 2020


Hi! Thanks for the patch!

See 2 minor comments below.

> diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h
> index 7a5454d1c..beb6a7528 100644
> --- a/src/lib/core/diag.h
> +++ b/src/lib/core/diag.h
> @@ -118,25 +118,8 @@ error_ref(struct error *e)
>  	e->refs++;
>  }
>  
> -static inline void
> -error_unref(struct error *e)

1. To reduce diff size and to keep inlining when
possible you can remove word 'static', and add

    extern inline void
    error_unref(struct error *e);

to diag.c.

Yeah, exactly 'extern inline', not just 'extern'.
I recently discovered that it is a special thing for
such cases.

> -{
> -	assert(e->refs > 0);
> -	struct error *to_delete = e;
> -	while (--to_delete->refs == 0) {
> -		/* Unlink error from lists completely.*/
> -		struct error *cause = to_delete->cause;
> -		assert(to_delete->effect == NULL);
> -		if (to_delete->cause != NULL) {
> -			to_delete->cause->effect = NULL;
> -			to_delete->cause = NULL;
> -		}
> -		to_delete->destroy(to_delete);
> -		if (cause == NULL)
> -			return;
> -		to_delete = cause;
> -	}
> -}
> +void
> +error_unref(struct error *e);
>  
> diff --git a/test/box/error.result b/test/box/error.result
> index df6d0ebc0..49e35b942 100644
> --- a/test/box/error.result
> +++ b/test/box/error.result
> @@ -831,3 +831,51 @@ assert(box.error.last() == e1)
> + | ...
> +err.prev
> + | ---
> + | - null
> + | ...
> +preve
> + | ---
> + | - '[string "return function(tuple) local json = require(''..."]:1: attempt to call
> + |   global ''require'' (a nil value)'
> + | ...
> +
> +s:drop()
> + | ---
> + | ...
> +box.schema.func.drop('runtimeerror')

2. Did you check that preve does not leak when GC starts working?
You can use setmetatable({}, {__mode = 'v'}) for that, see
examples by grepping " __mode = 'v' ".


More information about the Tarantool-patches mailing list