otrv4 / libotr-ng

A new implementation of OTR with support for version 4. This is a mirror of https://bugs.otr.im/otrv4/libotr-ng
Other
43 stars 9 forks source link

Memory leaks while executing some tests #39

Closed claucece closed 6 years ago

claucece commented 7 years ago

Currently, there seems to be three memory leaks (that show up randomly on ci):

==10767== Use of uninitialised value of size 8
==10767== at 0x5149819: encodeblock (b64.c:89)
==10767== by 0x51499BA: otrl_base64_encode (b64.c:108)
==10767== by 0x5149B5B: otrl_base64_otr_encode (b64.c:218)
==10767== by 0x4289ED: serialize_and_encode_data_msg (otrv4.c:1405)
==10767== by 0x428C1C: send_data_message (otrv4.c:1450)
==10767== by 0x428F69: otrv4_prepare_to_send_data_message (otrv4.c:1531)
==10767== by 0x42900C: otrv4_prepare_to_send_message (otrv4.c:1550)
==10767== by 0x42906F: otrv4_close_v4 (otrv4.c:1566)
==10767== by 0x42911E: otrv4_close (otrv4.c:1589)
==10767== by 0x41B599: otr4_client_disconnect (client.c:332)
==10767== by 0x40C4AB: test_invalid_auth_r_msg_in_not_waiting_auth_r (test_client.c:614)
==10767== by 0x4EA3A80: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10767== Uninitialised value was created by a stack allocation
==10767== at 0x4203AB: calculate_brace_key (key_management.c:352)
==10611== 16 bytes in 1 blocks are possibly lost in loss record 176 of 427
==10611== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10611== by 0x514ABC9: otrl_mem_malloc (mem.c:60)
==10611== by 0x57E4E89: do_malloc (global.c:912)
==10611== by 0x57E64D2: _gcry_malloc_secure_core (global.c:946)
==10611== by 0x57E64D2: _gcry_xmalloc_secure (global.c:1145)
==10611== by 0x57E6596: _gcry_xcalloc_secure (global.c:1190)
==10611== by 0x58A8259: _gcry_mpi_resize (mpiutil.c:187)
==10611== by 0x58A5FCB: mpi_fromstr (mpicoder.c:134)
==10611== by 0x58A5FCB: _gcry_mpi_scan (mpicoder.c:602)
==10611== by 0x57E23C8: gcry_mpi_scan (visibility.c:357)
==10611== by 0x41B34F: dh_init (dh.c:39)
==10611== by 0x40B30D: test_valid_identity_msg_in_waiting_auth_r_lower (test_client.c:647)
==10611== by 0x4EA3A80: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10611== by 0x4EA3C45: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
==10611== 32 bytes in 1 blocks are possibly lost in loss record 251 of 427
==10611== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10611== by 0x514ABC9: otrl_mem_malloc (mem.c:60)
==10611== by 0x57E4E89: do_malloc (global.c:912)
==10611== by 0x57E63CC: _gcry_malloc (global.c:936)
==10611== by 0x57E63CC: _gcry_xmalloc (global.c:1110)
==10611== by 0x58A80F1: _gcry_mpi_alloc_secure (mpiutil.c:105)
==10611== by 0x58A5CBE: _gcry_mpi_scan (mpicoder.c:519)
==10611== by 0x57E23C8: gcry_mpi_scan (visibility.c:357)
==10611== by 0x41B422: dh_keypair_generate (dh.c:66)
==10611== by 0x41C811: key_manager_generate_ephemeral_keys (key_management.c:115)
==10611== by 0x41EA1E: start_dake (otrv4.c:427)
==10611== by 0x421F76: receive_query_message (otrv4.c:467)
==10611== by 0x421F76: receive_message_v4_only (otrv4.c:1262)
==10611== by 0x421F76: otrv4_receive_message (otrv4.c:1292)
==10611== by 0x419907: otr4_client_receive (client.c:279)
claucece commented 7 years ago

Hey @natalieesk , I saw you referencing this issue. Are you working on it? If so, can you assign it to you here? it's just for clarity.. thanks! :)

natalieesk commented 6 years ago

This may have been fixed by the completion of #13. If no more flaky mem leaks occur in this next week, we can close this issue.

claucece commented 6 years ago

As found by @tuliocasagrande , these mem leaks still show up:

==26999== 16 bytes in 1 blocks are possibly lost in loss record 193 of 421
==26999==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x51555DC: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57F9069: do_malloc (global.c:912)
==26999==    by 0x57FA7F1: _gcry_malloc_secure_core (global.c:946)
==26999==    by 0x57FA7F1: _gcry_xmalloc_secure (global.c:1145)
==26999==    by 0x57FA8C6: _gcry_xcalloc_secure (global.c:1190)
==26999==    by 0x58BE314: _gcry_mpi_resize (mpiutil.c:187)
==26999==    by 0x58BC0EF: mpi_fromstr (mpicoder.c:134)
==26999==    by 0x58BC0EF: _gcry_mpi_scan (mpicoder.c:602)
==26999==    by 0x57F6448: gcry_mpi_scan (visibility.c:357)
==26999==    by 0x42A483: dh_init (dh.c:63)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999== 
==26999== 32 bytes in 1 blocks are possibly lost in loss record 280 of 421
==26999==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x51555DC: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57F9069: do_malloc (global.c:912)
==26999==    by 0x57FA6CB: _gcry_malloc (global.c:936)
==26999==    by 0x57FA6CB: _gcry_xmalloc (global.c:1110)
==26999==    by 0x58BE1F1: _gcry_mpi_alloc_secure (mpiutil.c:105)
==26999==    by 0x58BBBB4: _gcry_mpi_scan (mpicoder.c:601)
==26999==    by 0x57F6448: gcry_mpi_scan (visibility.c:357)
==26999==    by 0x42A43B: dh_init (dh.c:57)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA9BAD: g_test_run_suite (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999== 
==26999== 32 bytes in 1 blocks are possibly lost in loss record 281 of 421
==26999==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x51555DC: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57F9069: do_malloc (global.c:912)
==26999==    by 0x57FA6CB: _gcry_malloc (global.c:936)
==26999==    by 0x57FA6CB: _gcry_xmalloc (global.c:1110)
==26999==    by 0x58BE1F1: _gcry_mpi_alloc_secure (mpiutil.c:105)
==26999==    by 0x58BBBB4: _gcry_mpi_scan (mpicoder.c:601)
==26999==    by 0x57F6448: gcry_mpi_scan (visibility.c:357)
==26999==    by 0x42A45F: dh_init (dh.c:60)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA9BAD: g_test_run_suite (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999== 
==26999== 32 bytes in 1 blocks are possibly lost in loss record 282 of 421
==26999==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x51555DC: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57F9069: do_malloc (global.c:912)
==26999==    by 0x57FA6CB: _gcry_malloc (global.c:936)
==26999==    by 0x57FA6CB: _gcry_xmalloc (global.c:1110)
==26999==    by 0x58BE1F1: _gcry_mpi_alloc_secure (mpiutil.c:105)
==26999==    by 0x58BBBB4: _gcry_mpi_scan (mpicoder.c:601)
==26999==    by 0x57F6448: gcry_mpi_scan (visibility.c:357)
==26999==    by 0x42A483: dh_init (dh.c:63)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA9BAD: g_test_run_suite (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999== 
==26999== 392 bytes in 1 blocks are possibly lost in loss record 407 of 421
==26999==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x51555DC: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57F9069: do_malloc (global.c:912)
==26999==    by 0x57FA7F1: _gcry_malloc_secure_core (global.c:946)
==26999==    by 0x57FA7F1: _gcry_xmalloc_secure (global.c:1145)
==26999==    by 0x57FA8C6: _gcry_xcalloc_secure (global.c:1190)
==26999==    by 0x58BE314: _gcry_mpi_resize (mpiutil.c:187)
==26999==    by 0x58BC0EF: mpi_fromstr (mpicoder.c:134)
==26999==    by 0x58BC0EF: _gcry_mpi_scan (mpicoder.c:602)
==26999==    by 0x57F6448: gcry_mpi_scan (visibility.c:357)
==26999==    by 0x42A43B: dh_init (dh.c:57)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999== 
==26999== 392 bytes in 1 blocks are possibly lost in loss record 408 of 421
==26999==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x51555DC: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57F9069: do_malloc (global.c:912)
==26999==    by 0x57FA7F1: _gcry_malloc_secure_core (global.c:946)
==26999==    by 0x57FA7F1: _gcry_xmalloc_secure (global.c:1145)
==26999==    by 0x57FA8C6: _gcry_xcalloc_secure (global.c:1190)
==26999==    by 0x58BE314: _gcry_mpi_resize (mpiutil.c:187)
==26999==    by 0x58BC0EF: mpi_fromstr (mpicoder.c:134)
==26999==    by 0x58BC0EF: _gcry_mpi_scan (mpicoder.c:602)
==26999==    by 0x57F6448: gcry_mpi_scan (visibility.c:357)
==26999==    by 0x42A45F: dh_init (dh.c:60)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999== 
==26999== 400 bytes in 1 blocks are possibly lost in loss record 409 of 421
==26999==    at 0x4C2FD5F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26999==    by 0x5155664: ??? (in /usr/lib/x86_64-linux-gnu/libotr.so.5.1.1)
==26999==    by 0x57FA4A2: _gcry_realloc_core (global.c:998)
==26999==    by 0x57FA764: _gcry_xrealloc (global.c:1127)
==26999==    by 0x58BE336: _gcry_mpi_resize (mpiutil.c:179)
==26999==    by 0x58B7C69: _gcry_mpi_sub_ui (mpi-add.c:178)
==26999==    by 0x42A4B2: dh_init (dh.c:67)
==26999==    by 0x40AB6E: test_api_multiple_clients (test_api.c:644)
==26999==    by 0x4EA97DA: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA99A2: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA9BAD: g_test_run_suite (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
==26999==    by 0x4EA9BD0: g_test_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2)
claucece commented 6 years ago

Close as we are tracking over #81