Joachim Zobel wrote:
Hi.

I am currently trying to track down a glibc memory corruption. To do
this I tried the following (see below). This is done on prefork.

However no logging takes place. Is there something obvious I am doing
wrong?

Thx,
Joachim

----------------------------------------------------------------------
static apr_pool_t *p_cur = NULL;

void xml2_set_current_pool(apr_pool_t * p)
{
    // Needed for free-logging
    p_cur = p;
}

static void xml2_child_init(apr_pool_t * p, server_rec * s)
{
    xml2_set_current_pool(p);
....

In a function called from an external library I do

static void xml2_free(void *emem)
{
    ......

        ap_log_perror(APLOG_MARK, APLOG_DEBUG, 0, p_cur,
                "xml2_free will free %x.", mem);
        free(mem);
}

Two things:

1. You won't want to save the pool in a *static* p_cur if you have a threaded Apache. All the threads will clobber each others' p_cur values.
You might get away with this using Apache 1.3 (or with the prefork mpm).

2. The argument to xml2_free is named 'emem', but you pass 'mem' to ap_log_perror. Just a typo? Is 'mem' related to 'emem' somehow?

-tom-

Reply via email to