[sr-dev] git:master:2cd82d39: mem: q_malloc - better log message on ignoring double free

Daniel-Constantin Mierla miconda at gmail.com
Mon Sep 24 14:28:04 CEST 2018


Module: kamailio
Branch: master
Commit: 2cd82d39fe0fccf3237eb9947fd16b0be15c2270
URL: https://github.com/kamailio/kamailio/commit/2cd82d39fe0fccf3237eb9947fd16b0be15c2270

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-09-24T14:22:12+02:00

mem: q_malloc - better log message on ignoring double free

---

Modified: src/core/mem/q_malloc.c

---

Diff:  https://github.com/kamailio/kamailio/commit/2cd82d39fe0fccf3237eb9947fd16b0be15c2270.diff
Patch: https://github.com/kamailio/kamailio/commit/2cd82d39fe0fccf3237eb9947fd16b0be15c2270.patch

---

diff --git a/src/core/mem/q_malloc.c b/src/core/mem/q_malloc.c
index 0c3528544d..52d2ef722c 100644
--- a/src/core/mem/q_malloc.c
+++ b/src/core/mem/q_malloc.c
@@ -486,11 +486,15 @@ void qm_free(void* qmp, void* p)
 
 #ifdef DBG_QM_MALLOC
 	if (p>(void*)qm->last_frag_end || p<(void*)qm->first_frag){
-		LM_CRIT("BUG: bad pointer %p (out of memory block!)"
+		if(likely(cfg_get(core, core_cfg, mem_safety)==0))  {
+			LM_CRIT("BUG: bad pointer %p (out of memory block!)"
 				" called from %s: %s(%d) - aborting\n", p, file, func, line);
-		if(likely(cfg_get(core, core_cfg, mem_safety)==0))
 			abort();
-		else return;
+		} else {
+			LM_CRIT("BUG: bad pointer %p (out of memory block!)"
+				" called from %s: %s(%d) - ignoring\n", p, file, func, line);
+			return;
+		}
 	}
 #endif
 
@@ -499,12 +503,17 @@ void qm_free(void* qmp, void* p)
 #ifdef DBG_QM_MALLOC
 	qm_debug_frag(qm, f, file, line);
 	if (f->u.is_free){
-		LM_CRIT("BUG: freeing already freed pointer (%p),"
+		if(likely(cfg_get(core, core_cfg, mem_safety)==0)) {
+			LM_CRIT("BUG: freeing already freed pointer (%p),"
 				" called from %s: %s(%d), first free %s: %s(%ld) - aborting\n",
 				p, file, func, line, f->file, f->func, f->line);
-		if(likely(cfg_get(core, core_cfg, mem_safety)==0))
 			abort();
-		else return;
+		} else {
+			LM_CRIT("BUG: freeing already freed pointer (%p),"
+				" called from %s: %s(%d), first free %s: %s(%ld) - ignoring\n",
+				p, file, func, line, f->file, f->func, f->line);
+			return;
+		}
 	}
 	MDBG("freeing frag. %p alloc'ed from %s: %s(%ld)\n",
 			f, f->file, f->func, f->line);




More information about the sr-dev mailing list