Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread bronto

On 4/22/2010 1:46 PM, Andrej van der Zee wrote:

Hi Bronto,

   

http://lmgtfy.com/?q=apache+httpd+valgrind

 

Thank you for the tip :) You are funny!

Cheers,
Andrej
   

Hi,

yeah, i didn't mean no offense. I just thought that it's rather a FAQ ;)


Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Andrej van der Zee
Hi Bronto,

>
> http://lmgtfy.com/?q=apache+httpd+valgrind
>

Thank you for the tip :) You are funny!

Cheers,
Andrej


Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread bronto

On 4/22/2010 1:09 PM, Andrej van der Zee wrote:

Hi,


   

This and try running httpd through valgrind.

 

How can I do that?

Thanks,
Andrej
   


http://lmgtfy.com/?q=apache+httpd+valgrind


Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Andrej van der Zee
Hi,


>
> This and try running httpd through valgrind.
>

How can I do that?

Thanks,
Andrej


Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Andrej van der Zee
Hi,

> Do you create a background thread per apache process? Or do you have a
> single background thread that is used by all apache processes? Which
> hook creates the background thread?

The background thread is created by ap_hook_child_init, thus every
child process has one running background thread.

>
> It is possible that you create the thread once but you try to join it
> several times. I don't know if this is sufficient to get the symptoms
> that you see.

Even when I do not join at all, but just attempt to connect to the
database in the registered pool cleanup function for the child, I get
the segfault.

>
> Try compiling both apache and apr with debug symbols and run it in a
> debugger with -X (i.e. monoprocess).
> Place a breakpoint on line 134
> and see how many times you reach it.

Yes I'll try that soon.

Thank you,
Andrej


Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Ben Noordhuis
> Try compiling both apache and apr with debug symbols and run it in a
> debugger with -X (i.e. monoprocess). Place a breakpoint on line 134
> and see how many times you reach it.

This and try running httpd through valgrind.


Re: *** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-22 Thread Sorin Manolache
On Thu, Apr 22, 2010 at 05:47, Andrej van der Zee
 wrote:
> Hi,
>
> I have a question about apr_pool_cleanup_register for a child's pool.
> I register a cleanup function that is called when the pool is
> destroyed. In the cleanup function, I join a background thread that
> first writes some log to a database:
>
> static void mbrace_child_init(apr_pool_t *pool, server_rec *s)
> {
>    apr_pool_cleanup_register(pool, 0, &mbrace_bgthread_cleanup,
> apr_pool_cleanup_null);
> }
>
> static apr_status_t mbrace_bgthread_cleanup(void*)
> {
>    req_log_mngr->stop()
> }
>
> But, when it connects to the database in the background thread, it
> sometimes ends up in the error below. I do not fully understand why,
> but are there any restrictions to what I can do in the cleanup
> function?
>
> When running gdb on the generated core-dump, you can see that it
> happens on line 134.
>
> 125     APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator)
> 126     {
> 127         apr_uint32_t index;
> 128         apr_memnode_t *node, **ref;
> 129
> 130         for (index = 0; index < MAX_INDEX; index++) {
> 131             ref = &allocator->free[index];
> 132             while ((node = *ref) != NULL) {
> 133                 *ref = node->next;
> 134                 free(node);   < here it happens!!
> 135             }
> 136         }
> 137
> 138         free(allocator);
> 139     }
>
> Hopefully somebody can push me in the right direction.

Do you create a background thread per apache process? Or do you have a
single background thread that is used by all apache processes? Which
hook creates the background thread?

It is possible that you create the thread once but you try to join it
several times. I don't know if this is sufficient to get the symptoms
that you see.


Try compiling both apache and apr with debug symbols and run it in a
debugger with -X (i.e. monoprocess). Place a breakpoint on line 134
and see how many times you reach it.

S


*** glibc detected *** double free or corruption (!prev) in cleanup function

2010-04-21 Thread Andrej van der Zee
Hi,

I have a question about apr_pool_cleanup_register for a child's pool.
I register a cleanup function that is called when the pool is
destroyed. In the cleanup function, I join a background thread that
first writes some log to a database:

static void mbrace_child_init(apr_pool_t *pool, server_rec *s)
{
apr_pool_cleanup_register(pool, 0, &mbrace_bgthread_cleanup,
apr_pool_cleanup_null);
}

static apr_status_t mbrace_bgthread_cleanup(void*)
{
req_log_mngr->stop()
}

But, when it connects to the database in the background thread, it
sometimes ends up in the error below. I do not fully understand why,
but are there any restrictions to what I can do in the cleanup
function?

When running gdb on the generated core-dump, you can see that it
happens on line 134.

125 APR_DECLARE(void) apr_allocator_destroy(apr_allocator_t *allocator)
126 {
127 apr_uint32_t index;
128 apr_memnode_t *node, **ref;
129 
130 for (index = 0; index < MAX_INDEX; index++) {
131 ref = &allocator->free[index];
132 while ((node = *ref) != NULL) {
133 *ref = node->next;
134 free(node);   < here it happens!!
135 }
136 }
137 
138 free(allocator);
139 }

Hopefully somebody can push me in the right direction.

Thank you,
Andrej


*** glibc detected *** /usr/local/httpd-2.2.15/bin/httpd: double free
or corruption (!prev): 0x09461298 ***
=== Backtrace: =
/lib/tls/i686/cmov/libc.so.6[0xb7d5d454]
/lib/tls/i686/cmov/libc.so.6(cfree+0x96)[0xb7d5f4b6]
/usr/local/httpd-2.2.15/lib/libapr-1.so.0(apr_allocator_destroy+0x2e)[0xb7f3d2ce]
/usr/local/httpd-2.2.15/lib/libapr-1.so.0(apr_pool_destroy+0x235)[0xb7f3dfa5]
/usr/local/httpd-2.2.15/bin/httpd[0x80aa4c4]
/usr/local/httpd-2.2.15/bin/httpd[0x80aa986]
/usr/local/httpd-2.2.15/bin/httpd[0x80aabe3]
/usr/local/httpd-2.2.15/bin/httpd(ap_mpm_run+0x5fa)[0x80ab26a]
/usr/local/httpd-2.2.15/bin/httpd(main+0xac8)[0x80696d8]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7d04685]
/usr/local/httpd-2.2.15/bin/httpd[0x8068601]
=== Memory map: 
08048000-080c7000 r-xp  fe:00 1171716
/usr/local/httpd-2.2.15/bin/httpd
080c7000-080c8000 r--p 0007e000 fe:00 1171716
/usr/local/httpd-2.2.15/bin/httpd
080c8000-080cb000 rw-p 0007f000 fe:00 1171716
/usr/local/httpd-2.2.15/bin/httpd
080cb000-080ce000 rw-p 080cb000 00:00 0
09254000-09479000 rw-p 09254000 00:00 0  [heap]
b6465000-b6466000 ---p b6465000 00:00 0