In case unsupported format util_format_description return NULL, and dereference will produce segffault.
Created attachment 133978 [details] [review] gallium/{r600,radeonsi}: Fix segfault with color format Possible fix for r600/radionsi
What format is this happening with? There should be a description for every format, maybe except PIPE_FORMAT_NONE.
I have found this behaiviour because of error in my code when some time is_format_supported called with uninitialized value and had value > PIPE_FORMAT_COUNT. With check like: ----- for(int i=0; i<PIPE_FORMAT_COUNT; i++) { pscreen->is_format_supported(pscreen, i, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW); } ----- Such code has possible issues with: 73, 78, 79, 80, 81, 86 (holes in enum pipe_format).
Oh interesting. I think some of those formats were removed recently. I wonder if such call sites should be fixed. Nouveau calls util_format_is_supported up high in is_format_supported, I suspect that gets it out of trouble. Either way, is_format_supported or its callers should be fixed, not utility functions like util_format_get_first_non_void_channel.
Created attachment 134056 [details] [review] Updated version with changes related only to *_supported functions. I have deleted all changes not realted to *_supported functions. Change in src/gallium/auxiliary/util/u_format.c:util_format_is_supported - check that value of format in correct range (<PIPE_FORMAT_COUNT). Changes in src/gallium/drivers/{r600,radeonsi} - check for holes in format values.
Created attachment 134129 [details] [review] gallium/{r600,radeonsi}: Fix segfault with color format Fix radeonsi
In 'si_is_sampler_format_supported': 'util_format_get_first_non_void_channel' - tried to check 'struct util_format_description' before 'si_translate_texformat' call so we have segfault before check.
I have sent version patch to mesa-dev@lists.freedesktop.org. https://patchwork.freedesktop.org/series/30086/
Fixed in https://cgit.freedesktop.org/mesa/mesa/commit/?id=74d2456491fbd96eb3fb99cf8dd3595b223c2065
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.