Giter VIP home page Giter VIP logo

Comments (3)

jmayclin avatar jmayclin commented on June 7, 2024 1

My earlier understanding was correct. s2n_examples_test.c (and several others) have been leaking memory, but the Valgrind errors were being suppressed by an overly general valgrind suppression:

Memcheck:Leak
match-leak-kinds: reachable
...
fun:main

This is a wildcard suppression that suppresses all reachable leaks where the call stack starts with a function named main. Since we use ctest, this is effectively all possible memory leaks that we would have.

The reason that the errors in my PR weren't suppressed was because the call stack happened to be too long. We run valgrind with --num-callers=40 which "Specifies the maximum number of entries shown in stack traces that identify program locations".

This stack trace was then long enough that it didn't match the

...
fun:main

wildcard suppression, because fun:main had been dropped off of valgrind's tracking information. We can confirm this be looking at valgrind's auto-generated suppression for the error:

{
   <truncated by me>
   fun:s2n_test_example_negotiate
   fun:s2n_run_self_talk_test
}

We see that the suggested suppression starts with fun:s2n_run_self_talk_test rather than fun:main, which confirms that this was call-stack depth funkiness.

from s2n-tls.

jmayclin avatar jmayclin commented on June 7, 2024

On one hand, this has to be related to attribute/cleanup, because if I remove the DEFER_CLEANUP and just allow the process to exit normally there is no failure.

But on the other hand, this can't be related to attribute/cleanup because those aren't executed at exit : test case.

Perhaps there are some atexit shenanigans? I'll be spinning up an x86 instance and trying to reproduce the failures with the docker image.

from s2n-tls.

jmayclin avatar jmayclin commented on June 7, 2024

Some further investigation. I was able to locally reproduce using the CI docker image.

The other thing killing the process is actually valgrind. the exit code is simply the argument that we pass to valgrind: --error-exitcode=9. Valgrind kills the process because it detects a memory leak.

My current understanding is that my PR did not introduce a memory leak, rather it was some non functional change that made valgrind able to detect the memory leak. s2n_examples_test.c has always been "leaking" memory since DEFER_CLEANUP doesn't run when it's in the same scope as an exit function. But for an unknown reason Valgrind didn't care about that memory. This was confirmed by entirely removing the cleanup function from the server_process, and checking that Valgrind does not see a memory error.

Additionally, If the rest of the tests cases are removed then a memory leak is not reported in s2n_test_example_negoatiate. I tried adding some sleep statements in various places to see if this was related to timing, and that does not seem to be the case.

from s2n-tls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.