Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BACF89A10 for ; Mon, 19 Sep 2011 17:52:12 +0000 (UTC) Received: (qmail 97973 invoked by uid 500); 19 Sep 2011 17:52:11 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 97917 invoked by uid 500); 19 Sep 2011 17:52:11 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 97907 invoked by uid 99); 19 Sep 2011 17:52:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Sep 2011 17:52:11 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS,T_FRT_SLUT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.97.132.177] (HELO homiemail-a25.g.dreamhost.com) (208.97.132.177) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Sep 2011 17:52:03 +0000 Received: from homiemail-a25.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a25.g.dreamhost.com (Postfix) with ESMTP id 7235A678057 for ; Mon, 19 Sep 2011 10:51:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gbiv.com; h=content-type :mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; q=dns; s= gbiv.com; b=YuO65B6sos0pPCt2WN57Vf8OJzwrW8YV54lQbIEt7ojVxS4JHy0D TebXv6OK70mrnPocQpvshI0BG/16k0Tycfu6HMCnaTkn5JQggSwRfKL8a+9QjF8W UTe0Ign/7tln1Nt1BXP3mJt239MRmSbeg8IMIzPojj3fDq1W/1NLEU4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gbiv.com; h=content-type :mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; s=gbiv.com; bh=J3CFmkVkJvZlhGhU2RshBra4GqA=; b=FiNKs6Eqj/mgvZfI1quRE/arOCzz pEPWhDiE8ZNW7PF4Y7oSiUiuSzYbRz7Rm3MNFrNjdBeKAcc1EU5kMNXn1sC+87b7 SgqBYLIt31PNI73ZiCwFGzLl5v61lyUKD1wwZbienS4njny2eR7ZBOuJEAsMFJge NcBXolppPxOv3js= Received: from [192.168.1.84] (99-21-208-82.lightspeed.irvnca.sbcglobal.net [99.21.208.82]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: fielding@gbiv.com) by homiemail-a25.g.dreamhost.com (Postfix) with ESMTPSA id E096C678056 for ; Mon, 19 Sep 2011 10:51:29 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1084) Subject: Re: svn commit: r1172686 - in /httpd/httpd/trunk: ./ include/ modules/cache/ modules/examples/ modules/proxy/ modules/ssl/ server/ server/mpm/event/ server/mpm/worker/ From: "Roy T. Fielding" In-Reply-To: <20110919162544.67611238897D@eris.apache.org> Date: Mon, 19 Sep 2011 10:51:27 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <5F23A424-EA96-4D05-B12B-F2C27E007930@gbiv.com> References: <20110919162544.67611238897D@eris.apache.org> To: dev@httpd.apache.org X-Mailer: Apple Mail (2.1084) X-Virus-Checked: Checked by ClamAV on apache.org I am pretty sure that this kind of change has been vetoed numerous times in the past. What has changed? ....Roy On Sep 19, 2011, at 9:25 AM, sf@apache.org wrote: > Author: sf > Date: Mon Sep 19 16:25:42 2011 > New Revision: 1172686 >=20 > URL: http://svn.apache.org/viewvc?rev=3D1172686&view=3Drev > Log: > Add wrappers for malloc, calloc, realloc that check for out of memory > situations. Use them in most places where malloc, and friends are = used. > This results in clean error messages in an out of memory situation = instead of > segfaulting or silently malfunctioning. In some places, it just allows = to > remove some logging code. >=20 > PR 51568, PR 51569, PR 51571. >=20 > Modified: > httpd/httpd/trunk/CHANGES > httpd/httpd/trunk/include/ap_config.h > httpd/httpd/trunk/include/ap_mmn.h > httpd/httpd/trunk/include/httpd.h > httpd/httpd/trunk/modules/cache/cache_cache.c > httpd/httpd/trunk/modules/cache/cache_hash.c > httpd/httpd/trunk/modules/cache/cache_pqueue.c > httpd/httpd/trunk/modules/cache/mod_socache_dbm.c > httpd/httpd/trunk/modules/examples/mod_case_filter_in.c > httpd/httpd/trunk/modules/proxy/proxy_util.c > httpd/httpd/trunk/modules/ssl/ssl_util.c > httpd/httpd/trunk/server/config.c > httpd/httpd/trunk/server/main.c > httpd/httpd/trunk/server/mpm/event/event.c > httpd/httpd/trunk/server/mpm/worker/worker.c > httpd/httpd/trunk/server/mpm_unix.c > httpd/httpd/trunk/server/scoreboard.c > httpd/httpd/trunk/server/util.c >=20 > Modified: httpd/httpd/trunk/CHANGES > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=3D1172686&r1=3D= 1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/CHANGES [utf-8] (original) > +++ httpd/httpd/trunk/CHANGES [utf-8] Mon Sep 19 16:25:42 2011 > @@ -12,6 +12,10 @@ Changes with Apache 2.3.15 > PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric = Covener, > ] >=20 > + *) Add wrappers for malloc, calloc, realloc that check for out of = memory > + situations and use them in many places. PR 51568, PR 51569, PR = 51571. > + [Stefan Fritsch] > + > *) Fix cross-compilation of mod_cgi/mod_cgid when = APR_HAVE_STRUCT_RLIMIT is=20 > false but RLIMIT_* are defined. PR51371. [Eric Covener] >=20 >=20 > Modified: httpd/httpd/trunk/include/ap_config.h > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_config.h?rev=3D1= 172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/include/ap_config.h (original) > +++ httpd/httpd/trunk/include/ap_config.h Mon Sep 19 16:25:42 2011 > @@ -182,4 +182,12 @@ > #define ap_func_attr_sentinel > #endif >=20 > +#if ( defined(__GNUC__) && \ > + (__GNUC__ >=3D 4 || ( __GNUC__ =3D=3D 3 && __GNUC_MINOR__ >=3D = 4))) \ > + || __has_attribute(warn_unused_result) > +#define ap_func_attr_warn_unused_result = __attribute__((warn_unused_result)) > +#else > +#define ap_func_attr_warn_unused_result > +#endif > + > #endif /* AP_CONFIG_H */ >=20 > Modified: httpd/httpd/trunk/include/ap_mmn.h > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=3D1172= 686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/include/ap_mmn.h (original) > +++ httpd/httpd/trunk/include/ap_mmn.h Mon Sep 19 16:25:42 2011 > @@ -352,6 +352,8 @@ > * 20110724.5 (2.3.15-dev) add ap_set_accept_ranges() > * 20110724.6 (2.3.15-dev) add max_overlaps and max_reversals to = core_dir_config > * 20110724.7 (2.3.15-dev) add ap_random_insecure_bytes(), = ap_random_pick() > + * 20110724.8 (2.3.15-dev) add ap_abort_on_oom(), ap_malloc(), = ap_calloc(), > + * ap_realloc() > */ >=20 > #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ > @@ -359,7 +361,7 @@ > #ifndef MODULE_MAGIC_NUMBER_MAJOR > #define MODULE_MAGIC_NUMBER_MAJOR 20110724 > #endif > -#define MODULE_MAGIC_NUMBER_MINOR 7 /* 0...n */ > +#define MODULE_MAGIC_NUMBER_MINOR 8 /* 0...n */ >=20 > /** > * Determine if the server's current MODULE_MAGIC_NUMBER is at least a >=20 > Modified: httpd/httpd/trunk/include/httpd.h > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=3D11726= 86&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/include/httpd.h (original) > +++ httpd/httpd/trunk/include/httpd.h Mon Sep 19 16:25:42 2011 > @@ -2086,6 +2086,38 @@ AP_DECLARE(void) ap_random_insecure_byte > */ > AP_DECLARE(apr_uint32_t) ap_random_pick(apr_uint32_t min, apr_uint32_t = max); >=20 > +/** > + * Abort with a error message signifying out of memory > + */ > +AP_DECLARE(void) ap_abort_on_oom(void) __attribute__((noreturn)); > + > +/** > + * Wrapper for malloc() that calls ap_abort_on_oom() if out of memory > + * @param size size of the memory block > + * @return pointer to the allocated memory > + * @note ap_malloc may be implemented as a macro > + */ > +AP_DECLARE(void *) ap_malloc(size_t size) __attribute__((malloc)); > + > +/** > + * Wrapper for calloc() that calls ap_abort_on_oom() if out of memory > + * @param nelem number of elements to allocate memory for > + * @param size size of a single element > + * @return pointer to the allocated memory > + * @note ap_calloc may be implemented as a macro > + */ > +AP_DECLARE(void *) ap_calloc(size_t nelem, size_t size) = __attribute__((malloc)); > + > +/** > + * Wrapper for realloc() that calls ap_abort_on_oom() if out of = memory > + * @param ptr pointer to the old memory block (or NULL) > + * @param size new size of the memory block > + * @return pointer to the reallocated memory > + * @note ap_realloc may be implemented as a macro > + */ > +AP_DECLARE(void *) ap_realloc(void *ptr, size_t size) > + ap_func_attr_warn_unused_result; > + >=20 > #define AP_NORESTART APR_OS_START_USEERR + 1 >=20 >=20 > Modified: httpd/httpd/trunk/modules/cache/cache_cache.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_cache.c= ?rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/cache/cache_cache.c (original) > +++ httpd/httpd/trunk/modules/cache/cache_cache.c Mon Sep 19 16:25:42 = 2011 > @@ -58,7 +58,7 @@ cache_cache_t* cache_init(int max_entrie > cache_cache_free *free_entry) > { > cache_cache_t *tmp; > - tmp =3D malloc(sizeof(cache_cache_t)); > + tmp =3D ap_malloc(sizeof(cache_cache_t)); > tmp->max_entries =3D max_entries; > tmp->max_size =3D max_size; > tmp->current_size =3D 0; >=20 > Modified: httpd/httpd/trunk/modules/cache/cache_hash.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_hash.c?= rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/cache/cache_hash.c (original) > +++ httpd/httpd/trunk/modules/cache/cache_hash.c Mon Sep 19 16:25:42 = 2011 > @@ -77,23 +77,16 @@ struct cache_hash_t { > */ > static cache_hash_entry_t **alloc_array(cache_hash_t *ht, int max) > { > - return calloc(1, sizeof(*ht->array) * (max + 1)); > + return ap_calloc(1, sizeof(*ht->array) * (max + 1)); > } >=20 > cache_hash_t* cache_hash_make(apr_size_t size) > { > cache_hash_t *ht; > - ht =3D malloc(sizeof(cache_hash_t)); > - if (!ht) { > - return NULL; > - } > + ht =3D ap_malloc(sizeof(cache_hash_t)); > ht->count =3D 0; > ht->max =3D size; > ht->array =3D alloc_array(ht, ht->max); > - if (!ht->array) { > - free(ht); > - return NULL; > - } > return ht; > } >=20 > @@ -226,10 +219,7 @@ static cache_hash_entry_t **find_entry(c > if (he || !val) > return hep; > /* add a new entry for non-NULL values */ > - he =3D malloc(sizeof(*he)); > - if (!he) { > - return NULL; > - } > + he =3D ap_malloc(sizeof(*he)); > he->next =3D NULL; > he->hash =3D hash; > he->key =3D key; > @@ -260,8 +250,7 @@ void* cache_hash_set(cache_hash_t *ht, > cache_hash_entry_t **hep, *tmp; > const void *tval; > hep =3D find_entry(ht, key, klen, val); > - /* If hep =3D=3D NULL, then the malloc() in find_entry failed */ > - if (hep && *hep) { > + if (*hep) { > if (!val) { > /* delete entry */ > tval =3D (*hep)->val; >=20 > Modified: httpd/httpd/trunk/modules/cache/cache_pqueue.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/cache_pqueue.= c?rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/cache/cache_pqueue.c (original) > +++ httpd/httpd/trunk/modules/cache/cache_pqueue.c Mon Sep 19 16:25:42 = 2011 > @@ -50,17 +50,9 @@ cache_pqueue_t *cache_pq_init(apr_ssize_ > cache_pqueue_getpos get, > cache_pqueue_setpos set) > { > - cache_pqueue_t *q; > - > - if (!(q =3D malloc(sizeof(cache_pqueue_t)))) { > - return NULL; > - } > - > + cache_pqueue_t *q =3D ap_malloc(sizeof(cache_pqueue_t)); > /* Need to allocate n+1 elements since element 0 isn't used. */ > - if (!(q->d =3D malloc(sizeof(void*) * (n+1)))) { > - free(q); > - return NULL; > - } > + q->d =3D ap_malloc(sizeof(void*) * (n+1)); > q->avail =3D q->step =3D (n+1); /* see comment above about n+1 */ > q->pri =3D pri; > q->size =3D 1; > @@ -148,7 +140,7 @@ apr_status_t cache_pq_insert(cache_pqueu > /* allocate more memory if necessary */ > if (q->size >=3D q->avail) { > newsize =3D q->size + q->step; > - if (!(tmp =3D realloc(q->d, sizeof(void*) * newsize))) { > + if (!(tmp =3D ap_realloc(q->d, sizeof(void*) * newsize))) { > return APR_EGENERAL; > }; > q->d =3D tmp; >=20 > Modified: httpd/httpd/trunk/modules/cache/mod_socache_dbm.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/cache/mod_socache_d= bm.c?rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/cache/mod_socache_dbm.c (original) > +++ httpd/httpd/trunk/modules/cache/mod_socache_dbm.c Mon Sep 19 = 16:25:42 2011 > @@ -210,12 +210,7 @@ static apr_status_t socache_dbm_store(ap >=20 > /* create DBM value */ > dbmval.dsize =3D sizeof(apr_time_t) + nData; > - dbmval.dptr =3D (char *)malloc(dbmval.dsize); > - if (dbmval.dptr =3D=3D NULL) { > - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, > - "malloc error creating DBM value"); > - return APR_ENOMEM; > - } > + dbmval.dptr =3D (char *)ap_malloc(dbmval.dsize); > memcpy((char *)dbmval.dptr, &expiry, sizeof(apr_time_t)); > memcpy((char *)dbmval.dptr+sizeof(apr_time_t), ucaData, nData); >=20 >=20 > Modified: httpd/httpd/trunk/modules/examples/mod_case_filter_in.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_case_f= ilter_in.c?rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/examples/mod_case_filter_in.c (original) > +++ httpd/httpd/trunk/modules/examples/mod_case_filter_in.c Mon Sep 19 = 16:25:42 2011 > @@ -109,7 +109,7 @@ static apr_status_t CaseFilterInFilter(a > if(ret !=3D APR_SUCCESS) > return ret; >=20 > - buf =3D malloc(len); > + buf =3D ap_malloc(len); > for(n=3D0 ; n < len ; ++n) > buf[n] =3D apr_toupper(data[n]); >=20 >=20 > Modified: httpd/httpd/trunk/modules/proxy/proxy_util.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/proxy_util.c?= rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/proxy/proxy_util.c (original) > +++ httpd/httpd/trunk/modules/proxy/proxy_util.c Mon Sep 19 16:25:42 = 2011 > @@ -1384,7 +1384,7 @@ PROXY_DECLARE(char *) ap_proxy_define_ba > (*balancer)->lbmethod =3D lbmethod; >=20 > if (do_malloc) > - bshared =3D malloc(sizeof(proxy_balancer_shared)); > + bshared =3D ap_malloc(sizeof(proxy_balancer_shared)); > else > bshared =3D apr_palloc(p, sizeof(proxy_balancer_shared)); >=20 > @@ -1798,7 +1798,7 @@ PROXY_DECLARE(char *) ap_proxy_define_wo > * if called during config, we don't have shm setup yet, > * so just note the info for later. */ > if (do_malloc) > - wshared =3D malloc(sizeof(proxy_worker_shared)); /* will be = freed ap_proxy_share_worker */ > + wshared =3D ap_malloc(sizeof(proxy_worker_shared)); /* will = be freed ap_proxy_share_worker */ > else > wshared =3D apr_palloc(p, sizeof(proxy_worker_shared)); >=20 >=20 > Modified: httpd/httpd/trunk/modules/ssl/ssl_util.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_util.c?rev=3D= 1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/modules/ssl/ssl_util.c (original) > +++ httpd/httpd/trunk/modules/ssl/ssl_util.c Mon Sep 19 16:25:42 2011 > @@ -213,14 +213,14 @@ unsigned char *ssl_asn1_table_set(apr_ha > } > } > else { > - asn1 =3D malloc(sizeof(*asn1)); > + asn1 =3D ap_malloc(sizeof(*asn1)); > asn1->source_mtime =3D 0; /* used as a note for encrypted = private keys */ > asn1->cpData =3D NULL; > } >=20 > asn1->nData =3D length; > if (!asn1->cpData) { > - asn1->cpData =3D malloc(length); > + asn1->cpData =3D ap_malloc(length); > } >=20 > apr_hash_set(table, key, klen, asn1); >=20 > Modified: httpd/httpd/trunk/server/config.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/config.c?rev=3D11726= 86&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/config.c (original) > +++ httpd/httpd/trunk/server/config.c Mon Sep 19 16:25:42 2011 > @@ -772,10 +772,10 @@ AP_DECLARE(const char *) ap_setup_prelin > ap_loaded_modules =3D (module **)apr_palloc(process->pool, > sizeof(module *) * conf_vector_length); > if (!ap_module_short_names) > - ap_module_short_names =3D calloc(sizeof(char *), = conf_vector_length); > + ap_module_short_names =3D ap_calloc(sizeof(char *), = conf_vector_length); >=20 > if (!merger_func_cache) > - merger_func_cache =3D calloc(sizeof(merger_func), = conf_vector_length); > + merger_func_cache =3D ap_calloc(sizeof(merger_func), = conf_vector_length); >=20 > if (ap_loaded_modules =3D=3D NULL || ap_module_short_names =3D=3D = NULL > || merger_func_cache =3D=3D NULL) >=20 > Modified: httpd/httpd/trunk/server/main.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/main.c?rev=3D1172686= &r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/main.c (original) > +++ httpd/httpd/trunk/server/main.c Mon Sep 19 16:25:42 2011 > @@ -265,14 +265,10 @@ static void destroy_and_exit_process(pro > exit(process_exit_value); > } >=20 > -#define OOM_MESSAGE "[crit] Memory allocation failed, " \ > - "aborting process." APR_EOL_STR > - > /* APR callback invoked if allocation fails. */ > static int abort_on_oom(int retcode) > { > - write(STDERR_FILENO, OOM_MESSAGE, strlen(OOM_MESSAGE)); > - abort(); > + ap_abort_on_oom(); > return retcode; /* unreachable, hopefully. */ > } >=20 >=20 > Modified: httpd/httpd/trunk/server/mpm/event/event.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?re= v=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/mpm/event/event.c (original) > +++ httpd/httpd/trunk/server/mpm/event/event.c Mon Sep 19 16:25:42 = 2011 > @@ -1007,7 +1007,7 @@ static apr_status_t s_socket_add(void *u > { > s_baton_t *s =3D (s_baton_t*)user_baton; > /* XXXXX: recycle listener_poll_types */ > - listener_poll_type *pt =3D malloc(sizeof(*pt)); > + listener_poll_type *pt =3D ap_malloc(sizeof(*pt)); > pt->type =3D PT_SERF; > pt->baton =3D serf_baton; > pfd->client_data =3D pt; > @@ -1187,7 +1187,7 @@ static apr_status_t event_register_timed > } > else { > /* XXXXX: lol, pool allocation without a context from any = thread.Yeah. Right. MPMs Suck. */ > - te =3D malloc(sizeof(timer_event_t)); > + te =3D ap_malloc(sizeof(timer_event_t)); > APR_RING_ELEM_INIT(te, link); > } >=20 > @@ -1766,7 +1766,7 @@ static void create_listener_thread(threa > proc_info *my_info; > apr_status_t rv; >=20 > - my_info =3D (proc_info *) malloc(sizeof(proc_info)); > + my_info =3D (proc_info *) ap_malloc(sizeof(proc_info)); > my_info->pid =3D my_child_num; > my_info->tid =3D -1; /* listener thread doesn't have a = thread slot */ > my_info->sd =3D 0; > @@ -1865,12 +1865,7 @@ static void *APR_THREAD_FUNC start_threa > continue; > } >=20 > - my_info =3D (proc_info *) malloc(sizeof(proc_info)); > - if (my_info =3D=3D NULL) { > - ap_log_error(APLOG_MARK, APLOG_ALERT, errno, = ap_server_conf, > - "malloc: out of memory"); > - clean_child_exit(APEXIT_CHILDFATAL); > - } > + my_info =3D (proc_info *) ap_malloc(sizeof(proc_info)); > my_info->pid =3D my_child_num; > my_info->tid =3D i; > my_info->sd =3D 0; > @@ -2047,16 +2042,8 @@ static void child_main(int child_num_arg > /* clear the storage; we may not create all our threads = immediately, > * and we want a 0 entry to indicate a thread which was not = created > */ > - threads =3D (apr_thread_t **) calloc(1, > - sizeof(apr_thread_t *) * > - threads_per_child); > - if (threads =3D=3D NULL) { > - ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, > - "malloc: out of memory"); > - clean_child_exit(APEXIT_CHILDFATAL); > - } > - > - ts =3D (thread_starter *) apr_palloc(pchild, sizeof(*ts)); > + threads =3D ap_calloc(threads_per_child, sizeof(apr_thread_t *)); > + ts =3D apr_palloc(pchild, sizeof(*ts)); >=20 > apr_threadattr_create(&thread_attr, pchild); > /* 0 means PTHREAD_CREATE_JOINABLE */ >=20 > Modified: httpd/httpd/trunk/server/mpm/worker/worker.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?= rev=3D1172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/mpm/worker/worker.c (original) > +++ httpd/httpd/trunk/server/mpm/worker/worker.c Mon Sep 19 16:25:42 = 2011 > @@ -1006,7 +1006,7 @@ static void create_listener_thread(threa > proc_info *my_info; > apr_status_t rv; >=20 > - my_info =3D (proc_info *)malloc(sizeof(proc_info)); > + my_info =3D (proc_info *)ap_malloc(sizeof(proc_info)); > my_info->pid =3D my_child_num; > my_info->tid =3D -1; /* listener thread doesn't have a thread slot = */ > my_info->sd =3D 0; > @@ -1072,12 +1072,7 @@ static void * APR_THREAD_FUNC start_thre > continue; > } >=20 > - my_info =3D (proc_info *)malloc(sizeof(proc_info)); > - if (my_info =3D=3D NULL) { > - ap_log_error(APLOG_MARK, APLOG_ALERT, errno, = ap_server_conf, > - "malloc: out of memory"); > - clean_child_exit(APEXIT_CHILDFATAL); > - } > + my_info =3D (proc_info *)ap_malloc(sizeof(proc_info)); > my_info->pid =3D my_child_num; > my_info->tid =3D i; > my_info->sd =3D 0; > @@ -1271,14 +1266,8 @@ static void child_main(int child_num_arg > /* clear the storage; we may not create all our threads = immediately, > * and we want a 0 entry to indicate a thread which was not = created > */ > - threads =3D (apr_thread_t **)calloc(1, > - sizeof(apr_thread_t *) * = threads_per_child); > - if (threads =3D=3D NULL) { > - ap_log_error(APLOG_MARK, APLOG_ALERT, errno, ap_server_conf, > - "malloc: out of memory"); > - clean_child_exit(APEXIT_CHILDFATAL); > - } > - > + threads =3D (apr_thread_t **)ap_calloc(1, > + sizeof(apr_thread_t *) * = threads_per_child); > ts =3D (thread_starter *)apr_palloc(pchild, sizeof(*ts)); >=20 > apr_threadattr_create(&thread_attr, pchild); >=20 > Modified: httpd/httpd/trunk/server/mpm_unix.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_unix.c?rev=3D117= 2686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/mpm_unix.c (original) > +++ httpd/httpd/trunk/server/mpm_unix.c Mon Sep 19 16:25:42 2011 > @@ -75,7 +75,7 @@ static extra_process_t *extras; >=20 > void ap_register_extra_mpm_process(pid_t pid, ap_generation_t gen) > { > - extra_process_t *p =3D (extra_process_t = *)malloc(sizeof(extra_process_t)); > + extra_process_t *p =3D (extra_process_t = *)ap_malloc(sizeof(extra_process_t)); >=20 > p->next =3D extras; > p->pid =3D pid; >=20 > Modified: httpd/httpd/trunk/server/scoreboard.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/scoreboard.c?rev=3D1= 172686&r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/scoreboard.c (original) > +++ httpd/httpd/trunk/server/scoreboard.c Mon Sep 19 16:25:42 2011 > @@ -149,7 +149,7 @@ void ap_init_scoreboard(void *shared_sco >=20 > ap_calc_scoreboard_size(); > ap_scoreboard_image =3D > - calloc(1, sizeof(scoreboard) + server_limit * = sizeof(worker_score *)); > + ap_calloc(1, sizeof(scoreboard) + server_limit * = sizeof(worker_score *)); > more_storage =3D shared_score; > ap_scoreboard_image->global =3D (global_score *)more_storage; > more_storage +=3D sizeof(global_score); > @@ -325,13 +325,7 @@ int ap_create_scoreboard(apr_pool_t *p,=20 > #endif > { > /* A simple malloc will suffice */ > - void *sb_mem =3D calloc(1, scoreboard_size); > - if (sb_mem =3D=3D NULL) { > - ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf, > - "(%d)%s: cannot allocate scoreboard", > - errno, strerror(errno)); > - return HTTP_INTERNAL_SERVER_ERROR; > - } > + void *sb_mem =3D ap_calloc(1, scoreboard_size); > ap_init_scoreboard(sb_mem); > } >=20 >=20 > Modified: httpd/httpd/trunk/server/util.c > URL: = http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=3D1172686= &r1=3D1172685&r2=3D1172686&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- httpd/httpd/trunk/server/util.c (original) > +++ httpd/httpd/trunk/server/util.c Mon Sep 19 16:25:42 2011 > @@ -2583,3 +2583,36 @@ AP_DECLARE(void) ap_varbuf_free(struct a > } > vb->buf =3D NULL; > } > + > +#define OOM_MESSAGE "[crit] Memory allocation failed, " \ > + "aborting process." APR_EOL_STR > + > +AP_DECLARE(void) ap_abort_on_oom() > +{ > + write(STDERR_FILENO, OOM_MESSAGE, strlen(OOM_MESSAGE)); > + abort(); > +} > + > +AP_DECLARE(void *) ap_malloc(size_t size) > +{ > + void *p =3D malloc(size); > + if (p =3D=3D NULL && size !=3D 0) > + ap_abort_on_oom(); > + return p; > +} > + > +AP_DECLARE(void *) ap_calloc(size_t nelem, size_t size) > +{ > + void *p =3D calloc(nelem, size); > + if (p =3D=3D NULL && nelem !=3D 0 && size !=3D 0) > + ap_abort_on_oom(); > + return p; > +} > + > +AP_DECLARE(void *) ap_realloc(void *ptr, size_t size) > +{ > + void *p =3D realloc(ptr, size); > + if (p =3D=3D NULL && size !=3D 0) > + ap_abort_on_oom(); > + return p; > +} >=20 >=20