[Mesa-dev] [PATCH] nir: don't emit empty initializers for MSVC

Brian Paul brianp at vmware.com
Thu May 2 20:09:48 UTC 2019


On 05/02/2019 01:35 PM, Connor Abbott wrote:
> This will crash at runtime, since it'll construct a "struct transform" 
> with all NULL pointers, and then the loop below in ${pass_name}_block() 
> will see that there's one transform in the array since it uses 
> ARRAY_SIZE and then crash trying to access it.

Hmm, any ideas for how to fix this?

-Brian

> Running piglit with i965, or radeonsi will reproduce the crash.
> 
> On Thu, May 2, 2019 at 7:52 PM Brian Paul <brianp at vmware.com 
> <mailto:brianp at vmware.com>> wrote:
> 
>     This fixes a build failure with MSVC.
> 
>     ---
> 
>     I've compiled tested this, but not sure how to runtime test it.
>     ---
>       src/compiler/nir/nir_algebraic.py | 3 +++
>       1 file changed, 3 insertions(+)
> 
>     diff --git a/src/compiler/nir/nir_algebraic.py
>     b/src/compiler/nir/nir_algebraic.py
>     index 6db749e..dc25421 100644
>     --- a/src/compiler/nir/nir_algebraic.py
>     +++ b/src/compiler/nir/nir_algebraic.py
>     @@ -997,6 +997,9 @@ static const struct transform
>     ${pass_name}_state${state_id}_xforms[] = {
>       % for i in state_xforms:
>         { ${xforms[i].search.c_ptr(cache)},
>     ${xforms[i].replace.c_value_ptr(cache)}, ${xforms[i].condition_index} },
>       % endfor
>     +% if state_xforms == []: # avoid empty initializers for MSVC
>     +  0
>     +% endif
>       };
>       % endfor
> 
>     -- 
>     2.7.4
> 
>     _______________________________________________
>     mesa-dev mailing list
>     mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
>     https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>     <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fmesa-dev&data=02%7C01%7Cbrianp%40vmware.com%7C9a2c222ad2db4e0696b908d6cf355dca%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636924225451191768&sdata=TIk8%2BIqORtPKOvvdeJM2Yo4sMgpk3m97T2WZIKLYdxg%3D&reserved=0>
> 



More information about the mesa-dev mailing list