apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49847] apr_pcalloc should assert that memory is allocated
Date Tue, 31 Aug 2010 17:37:59 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49847

--- Comment #4 from dave b <db.pub.mail@gmail.com> 2010-08-31 13:37:56 EDT ---
(In reply to comment #3)
> Seems unwise to rob the caller from being able to respond to the condition
> (clearing this or other pools, freeing non-pool memory, crashing, asserting on
> their own)

I agree. However, there is a large number of users of this method(and some of
the others) in the wild who are not checking it is not null. 

It seems possible in:
apr_palloc(...)
to reach 

    node = active->next;
    if (size <= node_free_space(node)) {
        list_remove(node);
    }
    else {
        if ((node = allocator_alloc(pool->allocator, size)) == NULL) {
            if (pool->abort_fn)
                pool->abort_fn(APR_ENOMEM); /* HERE */

            return NULL; 
        }
    }

When you run the testdir (test). If you change the above to be:


.....
        if ((node = allocator_alloc(pool->allocator, size)) == NULL) {
            if (!   pool->abort_fn) /* note the ! added */ 
                pool->abort_fn(APR_ENOMEM); 

            return NULL; /* you end up here */ 
        }
    }
and you will fail one of the tests. This to me suggests that this scenario is
possible if the pool is like that one failed test *but* pool->abort_fn is not
true :) 

You notice I put the assert in the apr_pcalloc method right? and not the
apr_palloc method. I don't think this changes the fact that there is a large
number of mod_'s that are using these methods without checking it is null
first. 

So long as the caller is a child that can just be 're-born' I don't see this as
an issue. (for use with apache).

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message