[Tarantool-patches] [PATCH v2 4/4] fiber: refactor C backtrace and add changelog

Cyrill Gorcunov gorcunov at gmail.com
Mon Jul 12 15:35:48 MSK 2021


On Fri, Jul 09, 2021 at 02:03:53PM +0300, Egor Elchinov via Tarantool-patches wrote:
> +
> +int
> +backtrace_proc_cache_put(unw_word_t ip, const char *name, unw_word_t offset)
> +{
>  	struct proc_cache_entry *entry;
>  	struct mh_i64ptr_node_t node;
>  	mh_int_t k;
> @@ -99,39 +108,51 @@ get_proc_name(unw_cursor_t *unw_cur, unw_word_t *offset, bool skip_cache)
>  	if (proc_cache == NULL) {
>  		region_create(&cache_region, &cord()->slabc);
>  		proc_cache = mh_i64ptr_new();
> -		if (proc_cache == NULL) {
> -			unw_get_proc_name(unw_cur, proc_name, sizeof(proc_name),
> -					  offset);
> -			goto error;
> -		}
> +		if (proc_cache == NULL)
> +			return -1;
> +	}
> +
> +	size_t size;
> +	entry = region_alloc_object(&cache_region, typeof(*entry),
> +				    &size);
> +	if (entry == NULL)
> +		return -1;
> +
> +	node.key = ip;
> +	node.val = entry;
> +	entry->offset = offset;
> +	snprintf(entry->name, BACKTRACE_NAME_MAX, "%s", name);

Please add

	entry->name[BACKTRACE_NAME_MAX - 1] = 0;

...

The rest looks ok to me, thanks!


More information about the Tarantool-patches mailing list