-
Notifications
You must be signed in to change notification settings - Fork 51
Add Valgrind support and integrate memory checks into CI #177
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
base: main
Are you sure you want to change the base?
Conversation
- Updated Dockerfile to include Valgrind installation - Enhanced code-coverage.py to run tests with Valgrind - Uploaded coverage reports as artifacts on code-coverage.yml Change-Id: I8be2777baa59dceccfb130344e5a8aaf24939d97
9a6710c to
9f50944
Compare
|
@shamitha-shashidhara can you please briefly describe how the output can then be used? is it uploaded somewhere? |
|
Hi @marcmo, Instead of failing the CI pipeline immediately, we’ve chosen to upload the Valgrind output folder as an artifact, which can be Valgrind performs
|
|
The file memory-check.zip that you can download from this location, in turn contains another memory-check.zip archive. Maybe worth to have a look at? Further, looking at the contained results, the valgrind findings are primarily related to unit test code which is expected to use dynamic memory in contrast to OpenBSW production code. OpenBSW production code is not supposed to have relevant amounts of dynamic memory at all. So I wonder if you could identify any relevant findings for our main use case? An example for a processed output would be interesting. |
|
Hi @rolandreichweinbmw , thank you for the feedback! Yes, I noticed that there are two .zip files—memory-check.zip contains another memory-check.zip archive. I am currently uploading the outer memory-check.zip file as an artifact. However, when downloading artifacts from GitHub Actions, GitHub wraps the uploaded file inside another .zip named after the artifact itself. To avoid this double-wrapping, we can simply avoid uploading a pre-zipped memory-check.zip file. Regarding the Valgrind results: you're right that the findings are primarily related to unit test code, which is expected to use dynamic memory. In contrast, the OpenBSW production code is designed to avoid dynamic memory usage altogether. |
|
Does this mean we are still searching for a useful application of Valgrind for OpenBSW? |
|
yes, we are still searching for a useful application of Valgrind for OpenBSW. |
|
@shamitha-shashidhara, could you also summarize the difference between the sanitizers and valgrind? Thanks! |
|
I've put together a brief summary based on my findings about sanitizers and Valgrind. Here's a beginner’s perspective:
Memory leaks: Excellent (Memcheck very reliable) Thread issues: Limited detection Use-after-free: Detected Uninitialized memory: Detected reliably (Memcheck) Recompilation: Not required — works with existing binaries Ease of use: Can be installed via package manager and run directly with: ctest -T memcheck Performance: Very slow (tests can run 10–15 minutes or more, depending on machine speed) Best for: Deep memory analysis Debugging legacy binaries (no need to rebuild) Situations where performance isn’t critical
Memory leaks: Good (AddressSanitizer catches many, but not all leaks) Thread issues: Very strong (ThreadSanitizer is excellent) Use-after-free: Detected Uninitialized memory: Partially detected (MemorySanitizer) Recompilation: Required — must Ease of use: add -fsanitize=address,undefined to Cmakelists.txt Performance: Faster than Valgrind, but still take longer time. Best for: Faster feedback during development Detecting multithreading issues When you control the build and can recompile Sanitizer Type address (ASan) - Detects memory corruption like buffer overflows and use-after-free leak - Detects memory leaks undefined (UBSan) - Detects undefined behavior like integer overflows thread (TSan) - Detects data races in multithreaded programs MSan (MemorySanitizer) Not Supported in GCC MSan is not available in GCC. The -fsanitize=memory flag is not recognized by GCC. MSan is only supported in Clang. What happens if we use both of them at same time? If you build with Sanitizers enabled in CMake (e.g. -fsanitize=address): That binary is already instrumented. Running Valgrind memcheck on it usually causes conflicts (both tools hook into memory management). You’ll get crashes, “false positives,” or meaningless output. |

originates from CR #134850