Search the web
Sign In
New User? Sign Up
ClearSilver
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Memory leaks found by DMALLOC?   Message List  
Reply | Forward Message #1042 of 1351 |
Hi,

Here's what I've found with DMALLOC:

$ dmalloc_summarize.pl fastcgi < fastcgi.10983
size count gross function
1494 401044 total
284 1364 387376 ra=0x436818
1176 9 10584 _err_alloc+64> and ends at 0x43681c
<_err_alloc [neo_err.c:59]
240 2 480 hcreate_r
16 4 64 check_resize+76> and ends at
0x4389a8 <check_resize [ulist.c:37]
20 3 60 uListInit+68> and ends at 0x438a5c
<uListInit [ulist.c:61]



The part which leaks the most memory is around 0x436818, which is:

$ mips-linux-objdump -S fastcgi | grep -A 21 -B 25 436818
static NEOERR *_err_alloc(void)
{
4367d0: 3c1c0fbd lui gp,0xfbd
4367d4: 279c2c10 addiu gp,gp,11280
4367d8: 0399e021 addu gp,gp,t9
4367dc: 27bdffe0 addiu sp,sp,-32
4367e0: afbf0018 sw ra,24(sp)
4367e4: afbc0010 sw gp,16(sp)
NEOERR *err;

if (!UseFreeList || FreeList == NULL)
4367e8: 8f828018 lw v0,-32744(gp)
4367ec: 8f878018 lw a3,-32744(gp)
{
err = (NEOERR *)calloc (1, sizeof (NEOERR));
4367f0: 8f9988dc lw t9,-30500(gp)
4367f4: 8c4325d0 lw v1,9680(v0)
4367f8: 2405011c li a1,284
4367fc: 10600004 beqz v1,436810 <_err_alloc+0x40>
436800: 24040001 li a0,1
436804: 8ce625cc lw a2,9676(a3)
436808: 14c0000d bnez a2,436840 <_err_alloc+0x70>
43680c: 8fbf0018 lw ra,24(sp)
436810: 0320f809 jalr t9
436814: 00000000 nop
436818: 8fbc0010 lw gp,16(sp)
if (err == NULL)
{
ne_warn ("INTERNAL ERROR: Unable to allocate memory for
NEOERR");
return INTERNAL_ERR;
}
return err;
43681c: 00402821 move a1,v0
436820: 8f848024 lw a0,-32732(gp)
436824: 8f998aa4 lw t9,-30044(gp)
436828: 1040000f beqz v0,436868 <_err_alloc+0x98>
43682c: 24844130 addiu a0,a0,16688
}
else
{
err = FreeList;
FreeList = FreeList->next;
}
err->flags |= NE_IN_USE;
err->next = NULL;
return err;
}

These seem to be memory leaks. Can anyone confirm?

--Raphaël HUCK




Tue Jul 31, 2007 2:17 pm

raphael.huck
Offline Offline
Send Email Send Email

Forward
Message #1042 of 1351 |
Expand Messages Author Sort by Date

Hi, Here's what I've found with DMALLOC: $ dmalloc_summarize.pl fastcgi < fastcgi.10983 size count gross function 1494 401044 total 284...
raphael.huck
Offline Send Email
Jul 31, 2007
2:17 pm

Anything that returns a NEOERR is allocating memory on error. You must check the return value and call one of the methods to free the data, usually one of: ...
Brandon Long
blong42
Offline Send Email
Jul 31, 2007
9:05 pm

I've made a simple example to try and understand where these leaks come from: void fcgi_begin(void) { NEOERR *err; err = cgi_init(&cgi, NULL); ...
Raphaël HUCK
raphael.huck
Offline Send Email
Aug 2, 2007
1:48 pm

Is this the latest version? Much older versions used to use a FreeList for NEOERR's instead of always allocating new ones... but that still seems odd. Hmm,...
Brandon Long
blong42
Offline Send Email
Aug 2, 2007
11:14 pm

... Yes, I'm using the latest version (0.10.5). At the beginning of neo_err.c, there is this line: static int UseFreeList = 0; So I guess the FreeList is not...
Raphaël HUCK
raphael.huck
Offline Send Email
Aug 3, 2007
8:23 am

... I've found more information. I'm using the following wrappers for FastCGI: /* FCGI_fread wrapper for ClearSilver CGI */ int read_cb(void *ptr, char *data,...
Raphaël HUCK
raphael.huck
Offline Send Email
Aug 3, 2007
9:48 am

I've found the problem a long time ago, and forgot to post it. I just stumbled on my old message, so I figured I'd post a followup :) In fact the problem comes...
raphael.huck
Offline Send Email
Oct 27, 2008
5:25 pm

As it turns out, this was found (and fixed) by an engineer here a couple months back, I just didn't remember it. I really need to get a new relase out. Our...
Brandon Long
blong42
Offline Send Email
Nov 20, 2008
7:37 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help