Fix memory leak when a connection is unsuccessful

Review Request #3264 — Created June 12, 2024 and submitted

Information

ibis/ibis
default

Reviewers

Fix memory leak when a connection is unsuccessful

Ran Pidgin3 with a successful and unsuccessful connection in valgrind.

Summary ID
Fix memory leak when a connection is unsuccessful
7723068f615eec3e8dfaf41655b332cb94a74c18
Description From Last Updated

These should probably be in ibis_client_disconnect as the stream objects should only be valid while a connection is established. Can …

grimgrim
ivanhoe
  1. 
      
  2. With a failed SASL connection in Pidgin3 I got following leaks in valgrind:

    ==603383== 160 (64 direct, 96 indirect) bytes in 1 blocks are definitely lost in loss record 26,955 of 32,695
    ==603383==    at 0x4D6859F: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x4D4B86F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x4D4E322: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x4D4E67C: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x5D591FE: birb_queued_output_stream_new (birbqueuedoutputstream.c:150)
    ==603383==    by 0xFE3039D: ibis_client_start (ibisclient.c:794)
    ==603383==    by 0xFE2EC1A: ibis_client_connect_cb (ibisclient.c:253)
    ==603383==    by 0x588A6E2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    ...
    ==603383== 4,256 (64 direct, 4,192 indirect) bytes in 1 blocks are definitely lost in loss record 32,060 of 32,695
    ==603383==    at 0x4D6859F: g_type_create_instance (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x4D4B86F: ??? (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x4D4E322: g_object_new_valist (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0x4D4E67C: g_object_new (in /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0.8000.2)
    ==603383==    by 0xFE303D4: ibis_client_start (ibisclient.c:798)
    ==603383==    by 0xFE2EC1A: ibis_client_connect_cb (ibisclient.c:253)
    ==603383==    by 0x588A6E2: ??? (in /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0.8000.2)
    

    I'm not sure why these leaks don't show up with a successful connection but I checked valgrind with this patch and a successful connection and there were no double frees or invalid reads/writes.

  3. 
      
grim
  1. 
      
  2. ibis/ibisclient.c (Diff revision 1)
     
     
    Show all issues

    These should probably be in ibis_client_disconnect as the stream objects should only be valid while a connection is established.

    Can you put them there and run your test again to verify that that fixes it?

    1. Yes, that fixes it.

  3. 
      
ivanhoe
grim
  1. Great work, thanks!!

  2. 
      
grim
Review request changed
Status:
Completed