#203 Fix memory leaks
Merged by cipherboy. Opened by cipherboy.
cipherboy/gssproxy fix_resource_leaks  into  master

Download 203.patch

Before:

==13709== LEAK SUMMARY:
==13709==    definitely lost: 33,383 bytes in 484 blocks
==13709==    indirectly lost: 160,271 bytes in 1,295 blocks
==13709==      possibly lost: 0 bytes in 0 blocks
==13709==    still reachable: 26,945 bytes in 369 blocks
==13709==         suppressed: 0 bytes in 0 blocks

(18 errors)

After:

==25788== LEAK SUMMARY:
==25788==    definitely lost: 246 bytes in 17 blocks
==25788==    indirectly lost: 0 bytes in 0 blocks
==25788==      possibly lost: 0 bytes in 0 blocks
==25788==    still reachable: 14,997 bytes in 44 blocks
==25788==         suppressed: 0 bytes in 0 blocks

(4 errors)

There are leaks in the testsuite that I can fix if desired.

The four remaining errors in the daemon are:

==25788== 27 bytes in 1 blocks are definitely lost in loss record 5 of 37
==25788==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==25788==    by 0x6EF9D09: strdup (strdup.c:42)
==25788==    by 0x5B826CD: do_load_file (verto.c:260)
==25788==    by 0x5B82267: do_load_dir (verto.c:332)
==25788==    by 0x5B82C07: load_module (verto.c:426)
==25788==    by 0x5B83093: verto_default (verto.c:517)
==25788==    by 0x4073BC: init_event_loop (gp_init.c:110)
==25788==    by 0x405287: main (gssproxy.c:251)

(libverto - unknown fix status -- all paths appear to call verto_free() -- didn't explore)

==25788== 56 bytes in 1 blocks are definitely lost in loss record 18 of 37
==25788==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==25788==    by 0x5258F47: expandNextArg (popt.c:699)
==25788==    by 0x525A681: poptGetNextOpt (popt.c:1501)
==25788==    by 0x4051DA: main (gssproxy.c:191)

(libpopt -- fixed upstream)

==25788== 64 bytes in 4 blocks are definitely lost in loss record 22 of 37
==25788==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==25788==    by 0x6A082B5: UnknownInlinedFun (gssapi_alloc.h:99)
==25788==    by 0x6A082B5: generic_gss_create_empty_buffer_set (util_buffer_set.c:41)
==25788==    by 0x6A156F6: gss_inquire_cred_by_oid (g_inq_cred_oid.c:88)
==25788==    by 0x40A33D: get_impersonator_name (gp_creds.c:864)
==25788==    by 0x40A33D: gp_cred_allowed (gp_creds.c:957)
==25788==    by 0x413A90: gp_init_sec_context (gp_rpc_init_sec_context.c:111)
==25788==    by 0x40F098: gp_rpc_execute (gp_rpc_process.c:321)
==25788==    by 0x40F098: gp_rpc_process_call (gp_rpc_process.c:378)
==25788==    by 0x4087E8: gp_handle_query (gp_workers.c:430)
==25788==    by 0x4087E8: gp_worker_main (gp_workers.c:384)
==25788==    by 0x6C4E36C: start_thread (pthread_create.c:456)
==25788==    by 0x6F76B9E: clone (clone.S:97)

(krb5, fixed upstream)

==25788== 99 bytes in 11 blocks are definitely lost in loss record 23 of 37
==25788==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==25788==    by 0x40F153: gp_memdup (gp_conv.c:15)
==25788==    by 0x40F196: gp_conv_octet_string.part.0 (gp_conv.c:33)
==25788==    by 0x411030: gp_export_ctx_id_to_gssx (gp_export.c:649)
==25788==    by 0x413C19: gp_init_sec_context (gp_rpc_init_sec_context.c:148)
==25788==    by 0x40F098: gp_rpc_execute (gp_rpc_process.c:321)
==25788==    by 0x40F098: gp_rpc_process_call (gp_rpc_process.c:378)
==25788==    by 0x4087E8: gp_handle_query (gp_workers.c:430)
==25788==    by 0x4087E8: gp_worker_main (gp_workers.c:384)
==25788==    by 0x6C4E36C: start_thread (pthread_create.c:456)
==25788==    by 0x6F76B9E: clone (clone.S:97)

(unknown -- not quite sure if its due to rpc clean up or what).

rebased

Thank you for the PR; will review in more detail in a moment. I've backported the krb5 fix to fedora; will be present in krb5 >= 1.15.1-14.

Shouldn't this be a call to krb5_free_enctypes()?

Wouldn't it make more sense to do the allocation conditionally rather than performing it and then throwing it away?

Can you implement this change as a goto done; style cleanup pass?

Some comments inline.

rebased

Should be fixed. Also clears up remaining paths in main that would potentially leak.

rebased

Commit eae00113 fixes this pull-request

Pull-Request has been merged by ascheel@redhat.com

Commit 470cf4d7 fixes this pull-request

Pull-Request has been merged by ascheel@redhat.com

Commit eae00113 fixes this pull-request

Pull-Request has been merged by ascheel@redhat.com

Metadata