s2n-tls icon indicating copy to clipboard operation
s2n-tls copied to clipboard

S2N_DONT_MLOCK memory leak.

Open rday opened this issue 6 years ago • 0 comments

Problem:

Using S2N_DONT_MLOCK causes memory leaks in some tests.

$ valgrind --leak-check=full --run-libc-freeres=no -q --error-exitcode=9 --gen-suppressions=all --log-fd=2 --num-callers=40 --leak-resolution=high --undef-value-errors=no --trace-children=yes --suppressions=../s2n/tests/unit/valgrind.suppressions bin/s2n_session_ticket_test
Running /home/ubuntu/development/s2n/tests/unit/s2n_session_ticket_test.c ... PASSED        398 tests
==19643== 103 bytes in 1 blocks are definitely lost in loss record 1 of 5
==19643==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19643==    by 0x1EF14C: s2n_get_memory (s2n_mem.c:81)
==19643==    by 0x1EF308: s2n_realloc (s2n_mem.c:106)
==19643==    by 0x1E0F02: s2n_client_deserialize_with_session_ticket (s2n_resume.c:169)
==19643==    by 0x1E0FEE: s2n_client_deserialize_resumption_state (s2n_resume.c:187)
==19643==    by 0x1E1720: s2n_connection_set_session (s2n_resume.c:250)
==19643==    by 0x1AAAFA: main (s2n_session_ticket_test.c:514)
==19643==
{
   <insert_a_suppression_name_here>
   Memcheck:Leak
   match-leak-kinds: definite
   fun:calloc
   fun:s2n_get_memory
   fun:s2n_realloc
   fun:s2n_client_deserialize_with_session_ticket
   fun:s2n_client_deserialize_resumption_state
   fun:s2n_connection_set_session
   fun:main
}
==19643== 104 bytes in 1 blocks are definitely lost in loss record 2 of 5
==19643==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19643==    by 0x1EF14C: s2n_get_memory (s2n_mem.c:81)
==19643==    by 0x1EF308: s2n_realloc (s2n_mem.c:106)
==19643==    by 0x1E0F02: s2n_client_deserialize_with_session_ticket (s2n_resume.c:169)
==19643==    by 0x1E0FEE: s2n_client_deserialize_resumption_state (s2n_resume.c:187)
==19643==    by 0x1E1720: s2n_connection_set_session (s2n_resume.c:250)
==19643==    by 0x1A487D: main (s2n_session_ticket_test.c:387)
==19643==
{
   <insert_a_suppression_name_here>
   Memcheck:Leak
   match-leak-kinds: definite
   fun:calloc
   fun:s2n_get_memory
   fun:s2n_realloc
   fun:s2n_client_deserialize_with_session_ticket
   fun:s2n_client_deserialize_resumption_state
   fun:s2n_connection_set_session
   fun:main
}
==19643== 104 bytes in 1 blocks are definitely lost in loss record 3 of 5
==19643==    at 0x4C31B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19643==    by 0x1EF14C: s2n_get_memory (s2n_mem.c:81)
==19643==    by 0x1EF308: s2n_realloc (s2n_mem.c:106)
==19643==    by 0x1E0F02: s2n_client_deserialize_with_session_ticket (s2n_resume.c:169)
==19643==    by 0x1E0FEE: s2n_client_deserialize_resumption_state (s2n_resume.c:187)
==19643==    by 0x1E1720: s2n_connection_set_session (s2n_resume.c:250)
==19643==    by 0x1A7596: main (s2n_session_ticket_test.c:440)
==19643==
{
   <insert_a_suppression_name_here>
   Memcheck:Leak
   match-leak-kinds: definite
   fun:calloc
   fun:s2n_get_memory
   fun:s2n_realloc
   fun:s2n_client_deserialize_with_session_ticket
   fun:s2n_client_deserialize_resumption_state
   fun:s2n_connection_set_session
   fun:main
}
ubuntu:s2n_build/ $ unset S2N_DONT_MLOCK
ubuntu:s2n_build/ $ valgrind --leak-check=full --run-libc-freeres=no -q --error-exitcode=9 --gen-suppressions=all --log-fd=2 --num-callers=40 --leak-resolution=high --undef-value-errors=no --trace-children=yes --suppressions=../s2n/tests/unit/valgrind.suppressions bin/s2n_session_ticket_test
Running /home/ubuntu/development/s2n/tests/unit/s2n_session_ticket_test.c ... PASSED        398 tests

Proposed Solution:

Determine what is causing the leak and fix. Run all the tests using S2N_DONT_MLOCK to verify.

rday avatar Mar 10 '20 15:03 rday