Module: Mesa
Branch: master
Commit: 023ca40d80670ac0eee8c755ca5f54b1e7c2712e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=023ca40d80670ac0eee8c755ca5f54b1e7c2712e

Author: Brian Paul <[email protected]>
Date:   Fri Sep  9 13:59:20 2011 -0600

llvmpipe: add some null pointer checks

It's not clear if these are acceptable cases so issue a one-time warning
in debug builds when we hit them.

Fixes segfault in piglit fbo-mipmap-copypix test.

Reviewed-by: José Fonseca <[email protected]>

---

 src/gallium/drivers/llvmpipe/lp_rast.c       |   26 ++++++++++++++++++++++++++
 src/gallium/drivers/llvmpipe/lp_rast_debug.c |   10 +++++++++-
 2 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index dafadc1..2bb61fc 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -339,6 +339,15 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
    const unsigned tile_x = task->x, tile_y = task->y;
    unsigned x, y;
 
+   if (!variant) {
+      static boolean warned = FALSE;
+      if (!warned) {
+         debug_warning("null variant pointer");
+         warned = TRUE;
+      }
+      return;
+   }
+
    if (inputs->disable) {
       /* This command was partially binned and has been disabled */
       return;
@@ -391,6 +400,19 @@ lp_rast_shade_tile_opaque(struct lp_rasterizer_task *task,
    const struct lp_scene *scene = task->scene;
    unsigned i;
 
+   if (!task->state) {
+      /* This indicates that some sort of rendering command was queued
+       * before we set up the rasterization state.  Just returning here
+       * allows the piglit fbo-mipmap-copypix test to run/pass.
+       */
+      static boolean warned = FALSE;
+      if (!warned) {
+         debug_warning("null state pointer");
+         warned = TRUE;
+      }
+      return;
+   }
+
    LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
 
    /* this will prevent converting the layout from tiled to linear */
@@ -785,6 +807,10 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data )
    boolean debug = false;
 
    while (1) {
+      /* make sure these pointers aren't pointing to old data */
+      task->scene = NULL;
+      task->state = NULL;
+
       /* wait for work */
       if (debug)
          debug_printf("thread %d waiting for work\n", task->thread_index);
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_debug.c 
b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
index 03e67dc..b7568ec 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_debug.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_debug.c
@@ -62,6 +62,9 @@ get_variant( const struct lp_rast_state *state,
              const struct cmd_block *block,
              int k )
 {
+   if (!state)
+      return NULL;
+
    if (block->cmd[k] == LP_RAST_OP_SHADE_TILE ||
        block->cmd[k] == LP_RAST_OP_SHADE_TILE_OPAQUE ||
        block->cmd[k] == LP_RAST_OP_TRIANGLE_1 ||
@@ -140,9 +143,14 @@ debug_shade_tile(int x, int y,
                  char val)
 {
    const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
-   boolean blend = tile->state->variant->key.blend.rt[0].blend_enable;
+   boolean blend;
    unsigned i,j;
 
+   if (!tile->state)
+      return 0;
+
+   blend = tile->state->variant->key.blend.rt[0].blend_enable;
+
    if (inputs->disable)
       return 0;
 

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to