[Mesa-dev] [PATCH 1/2] genxml: Fix python crash when no dwords are found.

Dylan Baker dylan at pnwbakers.com
Fri Apr 7 17:29:41 UTC 2017


Quoting Rafael Antognolli (2017-04-07 09:52:16)
> If the 'dwords' dict is empty, max(dwords.keys()) throws an exception.
> This case could happen when we have an instruction that is only an array
> of other structs, with variable length.
> 
> Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
> ---
>  src/intel/genxml/gen_pack_header.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/intel/genxml/gen_pack_header.py b/src/intel/genxml/gen_pack_header.py
> index 2a70945..95215a1 100644
> --- a/src/intel/genxml/gen_pack_header.py
> +++ b/src/intel/genxml/gen_pack_header.py
> @@ -357,7 +357,7 @@ class Group(object):
>          if self.size > 0:
>              length = self.size // 32
>          else:
> -            length = max(dwords.keys()) + 1
> +            length = max(dwords.keys() + [0]) + 1

I'm not sure this is the right way to solve this, for one it wont work in
python3 because in python3 dict.keys() returns an iterator instead of a list,
and adding a dict_keys iterator and a list isn't valid either.

I think the right thing to do is:

if self.size > 0:
    length = ...
elif dwords:
    length = max(dwords.keys()) + 1
else:
    length = 1

This will only got down the max path if dwords is non-empty.

Dylan

>  
>          for index in range(length):
>              # Handle MBZ dwords
> 
> base-commit: 115e6847920bfe4e2f2d542d947212a2aeae5db7
> -- 
> git-series 0.9.1
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170407/2086832a/attachment.sig>


More information about the mesa-dev mailing list