Comments (3)
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:
s2n-tls/tests/unit/valgrind.suppressions
Lines 35 to 38 in 7f84701
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.
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.
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)
- Make S2N_CERT_AUTH_OPTIONAL the default for clients
- Support loading DER-encoded certificates and private keys
- consider adding a default negotiate timeout
- enforce result checking for s2n_stuffer methods
- Unpin dependencies after bumping MSRV beyond 1.70
- add visible debugging information for CI runs
- old libfuzzer used in CI
- old cppcheck used in CI
- Add schannel to integration tests HOT 1
- docs: Rust bindings need an explanation for Send/Sync impls HOT 1
- Add rustls to integration tests HOT 3
- test: SSLv2 integ test
- s2n_tls13_cert_verify_test doesn't run all cases HOT 1
- certificate_signature_preferences field contains unnecessary information HOT 2
- UBSAN triggers on `is_available` getting passed an incorrect function type HOT 5
- version 1.4.5: s2n_shutdown_test fail HOT 2
- clang format all .c and .h files
- make it easier to evaluate the impacts of changing security policies
- Clarify return values of IO APIs in the API documentation
- Do we still need s2n_ensure_memmove_trace? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s2n-tls.