Memcheck Execution Environment Plugin¤
Memory Error Detection Plugin
Memcheck integrates Valgrind's memory error detector for finding memory leaks, invalid memory access, and uninitialized memory usage during PANTHER experiments.
Plugin Type: Execution Environment
Verified Source Location:
plugins/environments/execution_environment/memcheck/
Overview¤
The Memcheck Execution Environment plugin integrates Valgrind's Memcheck tool into the PANTHER testing framework. Memcheck is a memory error detector that helps find memory leaks, use of uninitialized memory, invalid memory access, and other memory-related issues in programs.
Features¤
Performance Impact
Memcheck significantly slows down program execution (10-30x slower) and increases memory usage. Use only for debugging and testing scenarios, not performance benchmarking.
- Memory leak detection (full leak check)
- Uninitialized memory usage tracking
- Invalid memory access detection
- Origin tracking for better debugging
- Comprehensive memory error reporting
Configuration Options¤
Configuration Best Practices
Configure output_file
with descriptive names to easily identify memory analysis results from different test runs.
Parameter | Type | Default | Description |
---|---|---|---|
enabled |
Boolean | true |
Enable/disable the Memcheck environment |
output_file |
String | memcheck.log |
Path to write the memcheck output |
Output File Location
The output file path is relative to the test execution directory. Use absolute paths if you need outputs in specific locations.
Usage Example¤
Basic Configuration
This example shows the minimal configuration needed to enable Memcheck for memory error detection:
environments:
- name: "memcheck_env"
type: "execution_environment"
implementation: "memcheck"
config:
enabled: true
output_file: "custom_memcheck.log"
Resource Requirements
Ensure your system has sufficient memory and disk space when using Memcheck, as it can significantly increase resource usage.
Integration¤
The Memcheck Execution Environment integrates with:
- Service Managers - Prepends Valgrind Memcheck commands to service execution
- Test Framework - Captures and reports memory errors during test execution
- Result Collection - Memcheck logs can be included in test results
Implementation Details¤
Valgrind Command Structure
The plugin automatically constructs Valgrind commands with optimal settings for comprehensive memory analysis.
The plugin works by prepending Valgrind Memcheck commands to the service execution chain:
valgrind --tool=memcheck --leak-check=full --track-origins=yes --show-leak-kinds=all <service-command>
Debug Symbol Requirements
For best results, compile your applications with debug symbols (-g
flag) to get detailed source code references in memory error reports.
This allows for comprehensive memory usage analysis of the application under test.
Troubleshooting¤
Critical Considerations
Always review Memcheck output carefully as memory errors can lead to security vulnerabilities and unpredictable behavior.
Common Issues¤
- Performance Degradation !!! warning "Performance Impact" Memcheck significantly slows down program execution (5-20x slower). Consider using smaller test cases or running overnight for large applications.
- Memcheck significantly slows down program execution (5-20x slower)
-
Consider using smaller test cases when using Memcheck
-
False Positives !!! note "Third-Party Libraries" Some third-party libraries may generate warnings that are not actual issues. Create suppression files for known acceptable warnings.
- Some standard library and third-party code may trigger warnings
-
Consider using suppression files for known acceptable issues
-
Integration Problems !!! tip "Compilation Settings" Compile with
-O0 -g
flags for optimal Memcheck results. Higher optimization levels may hide some memory errors. - Ensure the executable is compiled with debugging symbols for best results
- Some optimizations might hide memory errors; compile with
-O0
when possible
Extension Points¤
Customization Options
Future versions may support additional Valgrind tools and custom command-line options for specialized memory analysis scenarios.
- Custom Valgrind options can be added through configuration parameters
- Integration with other Valgrind tools could be added in future versions
Advanced Usage
Consider creating custom suppression files for your specific application to filter out known acceptable warnings from third-party libraries.