Mesa (master): ra: assert against unsigned underflow in q_total

Andreas Boll ab at kemper.freedesktop.org
Fri Sep 12 14:08:27 UTC 2014


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

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Fri Sep  5 20:59:32 2014 -0400

ra: assert against unsigned underflow in q_total

q_total should never go below 0 (which is why it's defined as unsigned),
and if it does, then something is seriously wrong.

Signed-off-by: Connor Abbott <cwabbott0 at gmail.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/mesa/program/register_allocate.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index db2be5d..7faf672 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -434,6 +434,7 @@ decrement_q(struct ra_graph *g, unsigned int n)
       unsigned int n2_class = g->nodes[n2].class;
 
       if (n != n2 && !g->nodes[n2].in_stack) {
+         assert(g->nodes[n2].q_total >= g->regs->classes[n2_class]->q[n_class]);
 	 g->nodes[n2].q_total -= g->regs->classes[n2_class]->q[n_class];
       }
    }




More information about the mesa-commit mailing list