[nginx] Core: introduced the NGX_DEBUG_PALLOC macro.

Valentin Bartenev vbart at nginx.com
Wed Mar 23 14:45:44 UTC 2016


details:   http://hg.nginx.org/nginx/rev/ad2360782ecd
branches:  
changeset: 6455:ad2360782ecd
user:      Valentin Bartenev <vbart at nginx.com>
date:      Wed Mar 23 17:44:04 2016 +0300
description:
Core: introduced the NGX_DEBUG_PALLOC macro.

It allows to turn off accumulation of small pool allocations into a big
preallocated chunk of memory.  This is useful for debugging memory access
with sanitizer, since such accumulation can cover buffer overruns from
being detected.

diffstat:

 src/core/ngx_palloc.c |  4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r f61472978419 -r ad2360782ecd src/core/ngx_palloc.c
--- a/src/core/ngx_palloc.c	Wed Mar 23 17:44:04 2016 +0300
+++ b/src/core/ngx_palloc.c	Wed Mar 23 17:44:04 2016 +0300
@@ -122,9 +122,11 @@ ngx_reset_pool(ngx_pool_t *pool)
 void *
 ngx_palloc(ngx_pool_t *pool, size_t size)
 {
+#if !(NGX_DEBUG_PALLOC)
     if (size <= pool->max) {
         return ngx_palloc_small(pool, size, 1);
     }
+#endif
 
     return ngx_palloc_large(pool, size);
 }
@@ -133,9 +135,11 @@ ngx_palloc(ngx_pool_t *pool, size_t size
 void *
 ngx_pnalloc(ngx_pool_t *pool, size_t size)
 {
+#if !(NGX_DEBUG_PALLOC)
     if (size <= pool->max) {
         return ngx_palloc_small(pool, size, 0);
     }
+#endif
 
     return ngx_palloc_large(pool, size);
 }



More information about the nginx-devel mailing list