[Mesa-dev] [PATCH] i965: Avoid segfault in gen6_upload_state

Ian Romanick idr at freedesktop.org
Tue Feb 19 18:01:50 PST 2013


On 02/19/2013 04:27 PM, Carl Worth wrote:
> This fixes a bug introduced in commit 258453716f001eab1288d99765213 and
> triggered whenever "rb" is NULL.
>
> Fixes bug #59445:
>
> 	[SNB/IVB/HSW Bisected]Oglc draw-buffers2(advanced.blending.none) segfault
> 	https://bugs.freedesktop.org/show_bug.cgi?id=59445
> ---
>
> I don't know under what conditions "rb" might be NULL, but it's clear that
> it's possible and expected as there is earlier code in this function that
> checks it, (and sets rb_type specifically in that case). So if someone could
> help me write a more descriptive commit message, that would be great.
>
> Also, I notice that similar code in brw_cc.c uses a different condition here:
>
>         if (ctx->DrawBuffer->Visual.alphaBits == 0) {

I don't know what cases could cause rb to be NULL either.  There is code 
earlier that checks this case (near the top of the function), so it 
doesn't seem to be an error condition.  Could this be for the window? 
Ken or Eric should know for sure.

Either way, ctx->DrawBuffer->Visual contains either the window 
configuration or a mirror of the state for the current FBO.  It should 
always be safe to use that.  Using ctx->DrawBuffer->Visual.alphaBits 
will ensure that you get the correct answer even when rb is NULL.

> So an alternate fix could be to switch to something like that. Please let me
> know if one version or the other is cleaner, (and both could be made to
> match).
>
>   src/mesa/drivers/dri/i965/gen6_cc.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/gen6_cc.c b/src/mesa/drivers/dri/i965/gen6_cc.c
> index d32f636..7ac5d5f 100644
> --- a/src/mesa/drivers/dri/i965/gen6_cc.c
> +++ b/src/mesa/drivers/dri/i965/gen6_cc.c
> @@ -126,7 +126,7 @@ gen6_upload_blend_state(struct brw_context *brw)
>             * not read the alpha channel, but will instead use the correct
>             * implicit value for alpha.
>             */
> -         if (!_mesa_base_format_has_channel(rb->_BaseFormat, GL_TEXTURE_ALPHA_TYPE))
> +         if (rb && !_mesa_base_format_has_channel(rb->_BaseFormat, GL_TEXTURE_ALPHA_TYPE))
>            {
>               srcRGB = brw_fix_xRGB_alpha(srcRGB);
>               srcA = brw_fix_xRGB_alpha(srcA);
>



More information about the mesa-dev mailing list