[Mesa-dev] [PATCH 1/6] nir: don't segfault when printing variables with no name

Bas Nieuwenhuizen bas at basnieuwenhuizen.nl
Thu Jul 6 21:03:24 UTC 2017


Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>

On Thu, Jul 6, 2017 at 9:48 PM, Connor Abbott <connora at valvesoftware.com> wrote:
> From: Connor Abbott <cwabbott0 at gmail.com>
>
> While normally we give variables whose name field is NULL a temporary
> name when called from nir_print_shader(), when we were calling from
> nir_print_instr() we never bothered, meaning that we just segfaulted
> when trying to print out instructions with such a variable. Since
> nir_print_instr() is meant to be called while debugging, we don't need
> to bother too much about giving a consistent name, but we don't want to
> crash in the middle of debugging.
> ---
>  src/compiler/nir/nir_print.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
> index 66c0669..f4811fe 100644
> --- a/src/compiler/nir/nir_print.c
> +++ b/src/compiler/nir/nir_print.c
> @@ -257,7 +257,7 @@ static const char *
>  get_var_name(nir_variable *var, print_state *state)
>  {
>     if (state->ht == NULL)
> -      return var->name;
> +      return var->name ? var->name : "unnamed";
>
>     assert(state->syms);
>
> --
> 2.9.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list