[sr-dev] git:5.2:f7c990e2: core: qmalloc - print details of prev fragment when its tail is overwritten

Henning Westerholt hw at skalatan.de
Thu Jan 23 15:54:06 CET 2020


Module: kamailio
Branch: 5.2
Commit: f7c990e2ca6c7b2d43cf15723c71ba38065236e8
URL: https://github.com/kamailio/kamailio/commit/f7c990e2ca6c7b2d43cf15723c71ba38065236e8

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2020-01-23T15:53:22+01:00

core: qmalloc - print details of prev fragment when its tail is overwritten

- do it when check2 field is not touched

(cherry picked from commit bf1ba8d2d4519af50d44acfce5f34535fd1db8e0)

---

Modified: src/core/mem/q_malloc.c

---

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

---

diff --git a/src/core/mem/q_malloc.c b/src/core/mem/q_malloc.c
index 52d2ef722c..47d8344bd1 100644
--- a/src/core/mem/q_malloc.c
+++ b/src/core/mem/q_malloc.c
@@ -118,6 +118,7 @@ static  void qm_debug_check_frag(struct qm_block* qm, struct qm_frag* f,
 		const char* file, unsigned int line,
 		const char* efile, unsigned int eline)
 {
+	struct qm_frag *p;
 	if (f->check!=ST_CHECK_PATTERN){
 		LM_CRIT("BUG: qm: fragm. %p (address %p) "
 				"beginning overwritten (%lx)! Memory allocator was called "
@@ -147,6 +148,12 @@ static  void qm_debug_check_frag(struct qm_block* qm, struct qm_frag* f,
 				PREV_FRAG_END(f)->check1, PREV_FRAG_END(f)->check2, f,
 				(char*)f+sizeof(struct qm_frag), file, line, f->file, f->line,
 				efile, eline);
+		if(PREV_FRAG_END(f)->check2==END_CHECK_PATTERN2) {
+			p = FRAG_PREV(f);
+			LM_CRIT("BUG: qm: prev. fragm. tail overwritten [%p:%p]"
+					" - fragment marked by %s:%lu\n", p,
+					(char*)p+sizeof(struct qm_frag), p->file, p->line);
+		}
 		qm_status(qm);
 		abort();
 	}




More information about the sr-dev mailing list