[SR-Dev] git:master: core expr. eval: added bug catcher

Andrei Pelinescu-Onciul andrei at iptel.org
Mon May 4 23:39:44 CEST 2009


Module: sip-router
Branch: master
Commit: 087be8daf0bc279450732973618cec7fa719efde
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=087be8daf0bc279450732973618cec7fa719efde

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Mon May  4 22:02:49 2009 +0200

core expr. eval: added bug catcher

Added code for catching an easy to overlook bug (replacing in-line
a referenced rval during optimizing).

---

 rvalue.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/rvalue.c b/rvalue.c
index 7bfff5c..976945a 100644
--- a/rvalue.c
+++ b/rvalue.c
@@ -47,6 +47,8 @@
 
 #include "rvalue.h"
 
+#include <stdlib.h> /* abort() */
+
 /* minimum size alloc'ed for STR RVs (to accomodate
  * strops without reallocs) */
 #define RV_STR_EXTRA 80
@@ -2577,6 +2579,13 @@ static int rve_replace_with_val(struct rval_expr* rve, enum rval_type type,
 		if (rve_op_unary(rve->op)==0)
 			rve_destroy(rve->right.rve);
 	}else{
+		if (rve->left.rval.refcnt!=1){
+			BUG("trying to replace a referenced rval! (refcnt=%d)\n",
+					rve->left.rval.refcnt);
+			/* try to recover */
+			refcnt=rve->left.rval.refcnt;
+			abort(); /* find bugs quicker -- andrei */
+		}
 		rval_destroy(&rve->left.rval);
 	}
 	rval_init(&rve->left.rval, type, v, flags);




More information about the sr-dev mailing list