-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sanitizer / valgrind reports errors with tests #110
Comments
smart pointers? I have been thinking of moving to compile as C++ in order to get function decoration to help what I am doing. It might also be helpful to switch to using classes just to make inheritance easier. I don't know how smart pointers are going to interact with the context based allocations. Are you suggesting a custom pointer class? |
why closing the issue? the suggestion to move to C++ was not the content of the issue (more like a long term thing we could do). the issue is here that if we run the tests with sanitizers on, then they show leaks and uninitialized usage of variables |
Sorry I hit the wrong button |
dealing with context based allocations is much easier in C++ because of object oriented programming if wished |
actually I gave it a try to rename all files to cpp and change accordingly in cmake. already found interesting issues (more restrictive compiler and better warnings with C++): if (key == COSE_Header_Algorithm) {
if (value->type == CN_CBOR_INT) {
switch (value->v.uint) {
case COSE_Algorithm_Direct:
#ifdef USE_Direct_HKDF_AES_128
case COSE_Algorithm_Direct_HKDF_AES_128:
#endif
#ifdef USE_Direct_HKDF_AES_256
case COSE_Algorithm_Direct_HKDF_AES_256: Or I'm missing something? |
No you are not missing anything. This was an error on my part. I will probably make a go at doing cpp files over the weekend. |
The test driver has been switched to use smart pointers in some locations. Templates were pushed into C++ after I really stopped writing code in the language so I did not use a template but a macro. I am sure that this can be changed to use a template at some point. |
memory
if I do (memory sanitizer needs clang):
I get
use-of-uninitialized-value
errors and some tests failleak
If I do:
rm -rf build mkdir build cd build cmake .. -DCOSE_C_USE_SANITIZER=leak make -j ctest --verbose
I get errors like
LeakSanitizer: detected memory leaks
and all tests failThe same can be done with valgrind, see below
undefined
If I do:
rm -rf build mkdir build cd build cmake .. -DCOSE_C_USE_SANITIZER=undefined make -j ctest --verbose
I get errors like
runtime error: member access within misaligned address 0x55f6e7e1866c for type 'struct cn_cbor', which requires 8 byte alignment
valgrind
If I do:
rm -rf build mkdir build cd build cmake .. -DCOSE_C_VALGRIND_MEMORY_CHECK=ON make -j ctest -D ExperimentalMemCheck
I get:
eventually we start to think about converting to C++ to leverage start pointers/references which make memory issues a thing of the past
The text was updated successfully, but these errors were encountered: