[OPEN-ILS-DEV] valgrind finds memory leaks in libopensrf.so version 1.0.4

Steven Chan schan at vcn.bc.ca
Fri Mar 27 19:34:11 EDT 2009


When I run srfsh under the memory checker, 'valgrind', I find a number of 
memory leaks. Here are three scenarios:


1. Memory leak occurs after starting srfsh and then quitting.
-------------------------------------------------------------

$ valgrind --leak-check=full /openils/bin/srfsh
...
srfsh# quit
==20340== 
==20340== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 15 from 1)
==20340== malloc/free: in use at exit: 111,810 bytes in 275 blocks.
==20340== malloc/free: 1,451 allocs, 1,176 frees, 254,511 bytes allocated.
==20340== For counts of detected errors, rerun with: -v
==20340== searching for pointers to 275 not-freed blocks.
==20340== checked 285,440 bytes.
==20340== 
==20340== 
==20340== 4,494 (360 direct, 4,134 indirect) bytes in 9 blocks are definitely lost in loss record 10 of 15
==20340==    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
==20340==    by 0x4E42552: jsonNewObject (osrf_json_object.c:90)
==20340==    by 0x4E43044: jsonObjectClone (osrf_json_object.c:500)
==20340==    by 0x4E430C8: jsonObjectClone (osrf_json_object.c:521)
==20340==    by 0x4E44EDB: findMultiPathRecurse (osrf_json_tools.c:279)
==20340==    by 0x4E45741: jsonObjectFindPath (osrf_json_tools.c:233)
==20340==    by 0x4E3641F: osrfConfigGetValue (osrfConfig.c:87)
==20340==    by 0x4E3363D: osrfSystemBootstrapClientResc (osrf_system.c:335)
==20340==    by 0x4035E1: main (srfsh.c:86)
==20340== 
==20340== LEAK SUMMARY:
==20340==    definitely lost: 360 bytes in 9 blocks.
==20340==    indirectly lost: 4,134 bytes in 32 blocks.
==20340==      possibly lost: 0 bytes in 0 blocks.
==20340==    still reachable: 107,316 bytes in 234 blocks.
==20340==         suppressed: 0 bytes in 0 blocks.
==20340== Reachable blocks (those to which a pointer was found) are not shown.
==20340== To see them, rerun with: --leak-check=full --show-reachable=yes


2. Another leak if a request is handled.
----------------------------------------
I request an undefined method for the service 'open-ils.actor'.

$ valgrind --leak-check=full /openils/bin/srfsh
...
srfsh# request open-ils.actor "xxx"
...
srfsh# quit
==20374== 
==20374== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 15 from 1)
==20374== malloc/free: in use at exit: 113,496 bytes in 321 blocks.
==20374== malloc/free: 2,474 allocs, 2,153 frees, 399,662 bytes allocated.
==20374== For counts of detected errors, rerun with: -v
==20374== searching for pointers to 321 not-freed blocks.
==20374== checked 286,464 bytes.
==20374== 
==20374== 
==20374== 181 (104 direct, 77 indirect) bytes in 1 blocks are definitely lost in loss record 6 of 16
==20374==    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
==20374==    by 0x4E3EEE8: safe_malloc (utils.c:20)
==20374==    by 0x4E30B44: osrf_message_init (osrf_message.c:8)
==20374==    by 0x4E3304D: osrf_stack_transport_handler (osrf_stack.c:192)
==20374==    by 0x4E331F3: osrf_stack_process (osrf_stack.c:25)
==20374==    by 0x4E3221D: osrfAppSessionRequestRecv (osrf_app_session.c:111)
==20374==    by 0x402117: handle_request (srfsh.c:586)
==20374==    by 0x4030BD: parse_request (srfsh.c:270)
==20374==    by 0x4036EF: main (srfsh.c:159)
==20374== 
==20374== 
==20374== 4,997 (400 direct, 4,597 indirect) bytes in 10 blocks are definitely lost in loss record 11 of 16
==20374==    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
==20374==    by 0x4E42552: jsonNewObject (osrf_json_object.c:90)
==20374==    by 0x4E43044: jsonObjectClone (osrf_json_object.c:500)
==20374==    by 0x4E430C8: jsonObjectClone (osrf_json_object.c:521)
==20374==    by 0x4E44EDB: findMultiPathRecurse (osrf_json_tools.c:279)
==20374==    by 0x4E45741: jsonObjectFindPath (osrf_json_tools.c:233)
==20374==    by 0x4E3641F: osrfConfigGetValue (osrfConfig.c:87)
==20374==    by 0x4E3363D: osrfSystemBootstrapClientResc (osrf_system.c:335)
==20374==    by 0x4035E1: main (srfsh.c:86)
==20374== 
==20374== LEAK SUMMARY:
==20374==    definitely lost: 504 bytes in 11 blocks.
==20374==    indirectly lost: 4,674 bytes in 38 blocks.
==20374==      possibly lost: 0 bytes in 0 blocks.
==20374==    still reachable: 108,318 bytes in 272 blocks.
==20374==         suppressed: 0 bytes in 0 blocks.
==20374== Reachable blocks (those to which a pointer was found) are not shown.
==20374== To see them, rerun with: --leak-check=full --show-reachable=yes



3. Another leak detected if a login is handled but only after an 
introspection. 
------------------------------------------------------------------------------- 
No leak is detected for an introspect, a login, or a login followed by an 
introspect.

$ valgrind --leak-check=full /openils/bin/srfsh
...
srfsh# introspect open-ils.actor
...
srfsh# login steven xxxx
...
srfsh# quit
==20330== 
==20330== ERROR SUMMARY: 12 errors from 6 contexts (suppressed: 15 from 1)
==20330== malloc/free: in use at exit: 218,525 bytes in 2,852 blocks.
==20330== malloc/free: 136,177 allocs, 133,325 frees, 11,374,183 bytes allocated.
==20330== For counts of detected errors, rerun with: -v
==20330== searching for pointers to 2,852 not-freed blocks.
==20330== checked 390,544 bytes.
==20330== 
==20330== 
==20330== 4,997 (400 direct, 4,597 indirect) bytes in 10 blocks are definitely lost in loss record 10 of 23
==20330==    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
==20330==    by 0x4E42552: jsonNewObject (osrf_json_object.c:90)
==20330==    by 0x4E43044: jsonObjectClone (osrf_json_object.c:500)
==20330==    by 0x4E430C8: jsonObjectClone (osrf_json_object.c:521)
==20330==    by 0x4E44EDB: findMultiPathRecurse (osrf_json_tools.c:279)
==20330==    by 0x4E45741: jsonObjectFindPath (osrf_json_tools.c:233)
==20330==    by 0x4E3641F: osrfConfigGetValue (osrfConfig.c:87)
==20330==    by 0x4E3363D: osrfSystemBootstrapClientResc (osrf_system.c:335)
==20330==    by 0x4035E1: main (srfsh.c:86)
==20330== 
==20330== 
==20330== 1,006 (64 direct, 942 indirect) bytes in 2 blocks are definitely lost in loss record 13 of 23
==20330==    at 0x4C22FAB: malloc (vg_replace_malloc.c:207)
==20330==    by 0x4E38CE1: osrfNewListSize (osrf_list.c:13)
==20330==    by 0x4E42F95: jsonObjectPush (osrf_json_object.c:222)
==20330==    by 0x4E45856: jsonObjectFindPath (osrf_json_tools.c:257)
==20330==    by 0x4E3641F: osrfConfigGetValue (osrfConfig.c:87)
==20330==    by 0x4E32920: osrfAppSessionClientInit (osrf_app_session.c:247)
==20330==    by 0x4020C6: handle_request (srfsh.c:572)
==20330==    by 0x4030BD: parse_request (srfsh.c:270)
==20330==    by 0x402BA4: handle_login (srfsh.c:353)
==20330==    by 0x403433: parse_request (srfsh.c:291)
==20330==    by 0x4036EF: main (srfsh.c:159)
==20330== 
==20330== LEAK SUMMARY:
==20330==    definitely lost: 464 bytes in 12 blocks.
==20330==    indirectly lost: 5,539 bytes in 44 blocks.
==20330==      possibly lost: 0 bytes in 0 blocks.
==20330==    still reachable: 212,522 bytes in 2,796 blocks.
==20330==         suppressed: 0 bytes in 0 blocks.
==20330== Reachable blocks (those to which a pointer was found) are not shown.
==20330== To see them, rerun with: --leak-check=full --show-reachable=yes

I'll try to track down the memory leaks in more detail.
I wonder if valgrind has ever been applied to libopensrf.so?

--
Steven Chan
Sitka project
BC Evergreen



More information about the Open-ils-dev mailing list