[asterisk-bugs] [Asterisk 0017234]: Memory leak in manager.c

Asterisk Bug Tracker noreply at bugs.digium.com
Fri May 14 09:26:35 CDT 2010


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=17234 
====================================================================== 
Reported By:                mav3rick
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   17234
Category:                   Core/ManagerInterface
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     acknowledged
Target Version:             1.6.2.9
Asterisk Version:           1.6.2.7-rc2 
JIRA:                       SWP-1333 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2010-04-23 06:02 CDT
Last Modified:              2010-05-14 09:26 CDT
====================================================================== 
Summary:                    Memory leak in manager.c
Description: 
I detected a memory leak in manager.c, on latest Asterisk 1.6.2.7-rc2.
Leak is reproductible in 1.6.2.6.

   6622144 bytes in 30993 allocations in file 'manager.c'
   7100873 bytes in 33065 allocations in file 'manager.c'
   7352505 bytes in 34160 allocations in file 'manager.c'
   7636791 bytes in 35405 allocations in file 'manager.c'
   8039968 bytes in 37165 allocations in file 'manager.c'
   9430346 bytes in 43322 allocations in file 'manager.c'

I'm sending Originate (async) AMI commands using the built-in HTTP
server.

Attached: valgrind run with --leak-check=full --show-reachable=yes, and
"memory show allocations". Asterisk was compiled with MALLOC_DEBUG and
DONT_OPTIMIZE.


====================================================================== 

---------------------------------------------------------------------- 
 (0121905) mav3rick (reporter) - 2010-05-14 09:26
 https://issues.asterisk.org/view.php?id=17234#c121905 
---------------------------------------------------------------------- 
This is what we tried so far:
- we tried to call the WaitEvent action, events are successfully returned
to the HTTP client but not freed in the event queue,
- setting "Events=off" in the Login action does not work,
- removing read rights in the AMI user does not work.

"manager show eventq" shows a LOT OF events with "usecount: 0".

Aren't they supposed to be freed by "purge_event" ? If I correctly read
the function comment : 

"" Purge unused events. Remove elements from the head as long as their
usecount is 0 and there is a next element. ""

I made sure the function is called by adding ast_log, it is every few
seconds.

But the queue is not freed.

Maybe there is a bug after all ?

asterisk -rx 'memory show summary manager.c' :

      3420 bytes in 3 allocations in function 'action_originate' of
'manager.c'
       136 bytes in 4 allocations in function '__init_manager' of
'manager.c'
      1608 bytes in 67 allocations in function 'ast_manager_register2' of
'manager.c'
      1313 bytes in 21 allocations in function 'astman_get_variables' of
'manager.c'
    558400 bytes in 200 allocations in function 'generic_http_callback' of
'manager.c'
   6700264 bytes in 31041 allocations in function 'append_event' of
'manager.c'
7265141 bytes allocated in 31336 allocations


The two "growing" allocations are (from "memory show allocations
manager.c") :

      2792 bytes allocated in generic_http_callback at line  3833 of
manager.c
       166 bytes allocated in         append_event at line  3277 of
manager.c

both lines appear a few thousand times.

The fastest growing allocations are the event queue.

If there is no bug, how can we "flush" the manager queue ? 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-05-14 09:26 mav3rick       Note Added: 0121905                          
======================================================================




More information about the asterisk-bugs mailing list