Skip to content

Commit

Permalink
core: qmalloc - print details of prev fragment when its tail is overw…
Browse files Browse the repository at this point in the history
…ritten

- do it when check2 field is not touched

(cherry picked from commit bf1ba8d)
  • Loading branch information
miconda authored and henningw committed Jan 23, 2020
1 parent 7bebd65 commit f7c990e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/mem/q_malloc.c
Expand Up @@ -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 "
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit f7c990e

Please sign in to comment.