Browse code

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

- do it when check2 field is not touched

Daniel-Constantin Mierla authored on 03/11/2019 09:30:09
Showing 1 changed files
... ...
@@ -118,6 +118,7 @@ static  void qm_debug_check_frag(struct qm_block* qm, struct qm_frag* f,
118 118
 		const char* file, unsigned int line,
119 119
 		const char* efile, unsigned int eline)
120 120
 {
121
+	struct qm_frag *p;
121 122
 	if (f->check!=ST_CHECK_PATTERN){
122 123
 		LM_CRIT("BUG: qm: fragm. %p (address %p) "
123 124
 				"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,
147 147
 				PREV_FRAG_END(f)->check1, PREV_FRAG_END(f)->check2, f,
148 148
 				(char*)f+sizeof(struct qm_frag), file, line, f->file, f->line,
149 149
 				efile, eline);
150
+		if(PREV_FRAG_END(f)->check2==END_CHECK_PATTERN2) {
151
+			p = FRAG_PREV(f);
152
+			LM_CRIT("BUG: qm: prev. fragm. tail overwritten [%p:%p]"
153
+					" - fragment marked by %s:%lu\n", p,
154
+					(char*)p+sizeof(struct qm_frag), p->file, p->line);
155
+		}
150 156
 		qm_status(qm);
151 157
 		abort();
152 158
 	}