-
Notifications
You must be signed in to change notification settings - Fork 23
RDKB-63722:Analyze and fix/mitigate memory leaks from curl_easy_perform calls #283
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
Changes from all commits
eeaada0
9d3015c
9f9e159
29ad453
e56cd12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| CC = gcc | ||
| CFLAGS = -Wall -Wextra -g -O0 | ||
| LDFLAGS = -lcurl -lpthread | ||
|
|
||
| TARGET = memory_verifier | ||
|
|
||
| .PHONY: all clean run help valgrind-investigate | ||
|
|
||
| all: $(TARGET) | ||
| @echo "" | ||
| @echo "✓ Memory Verifier built successfully: $(TARGET)" | ||
| @echo " Run with: make run" | ||
| @echo "" | ||
|
|
||
| $(TARGET): memory_verifier.c | ||
| $(CC) $(CFLAGS) -o $(TARGET) memory_verifier.c $(LDFLAGS) | ||
|
|
||
| run: $(TARGET) | ||
| @echo "🔍 Running Memory Leak Verification..." | ||
| @echo "" | ||
| ./$(TARGET) | ||
|
|
||
| valgrind-investigate: $(TARGET) | ||
| @echo "🧪 Running SSL Memory Investigation..." | ||
| @echo "" | ||
| @if [ -f "investigate_ssl_memory.sh" ]; then \ | ||
| chmod +x investigate_ssl_memory.sh 2>/dev/null || true; \ | ||
| ./investigate_ssl_memory.sh; \ | ||
| elif [ -f "investigate_ssl_memory.bat" ]; then \ | ||
| cmd //c investigate_ssl_memory.bat; \ | ||
| else \ | ||
| echo "❌ Investigation script not found"; \ | ||
| exit 1; \ | ||
| fi | ||
|
|
||
| clean: | ||
| rm -f $(TARGET) | ||
| rm -f *.log *.out *.txt valgrind_*.sh | ||
| @echo "✓ Cleaned memory verifier and investigation files" | ||
|
|
||
| help: | ||
| @echo "Memory Leak Verifier with Valgrind Integration" | ||
| @echo "==============================================" | ||
| @echo "" | ||
| @echo "Standalone tool to verify curl/OpenSSL has no memory leaks" | ||
| @echo "" | ||
| @echo "Commands:" | ||
| @echo " make - Build the verifier" | ||
| @echo " make run - Build and run verification (RECOMMENDED)" | ||
| @echo " make valgrind-investigate - Run SSL memory investigation (NEW)" | ||
| @echo " make clean - Remove build artifacts and logs" | ||
| @echo " make help - Show this help" | ||
| @echo "" | ||
| @echo "Quick Start:" | ||
| @echo " make run # Standard memory verification" | ||
| @echo " make valgrind-investigate # Investigate SSL memory increase" | ||
| @echo "" | ||
| @echo "Standard Tests:" | ||
| @echo " ✓ Basic HTTP client memory growth" | ||
| @echo " ✓ Handle reuse and connection pooling" | ||
| @echo " ✓ Memory stability over time" | ||
| @echo " ✓ Library version compatibility" | ||
| @echo "" | ||
| @echo "NEW: Valgrind Investigation (for SSL 3484KB→3608KB issue):" | ||
| @echo " ✓ Pool baseline analysis" | ||
| @echo " ✓ Reset fix impact analysis" | ||
| @echo " ✓ Comparative leak assessment" | ||
| @echo " ✓ SSL/OpenSSL deep investigation" | ||
| @echo "" | ||
| @echo "Individual Valgrind Tests:" | ||
| @echo " ./memory_verifier --valgrind-pool # Baseline" | ||
| @echo " ./memory_verifier --valgrind-reset # Reset fix" | ||
| @echo " ./memory_verifier --post-analysis # Compare" | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,166 @@ | ||||||||||||
| # Memory Verifier | ||||||||||||
|
|
||||||||||||
| **Standalone tool to verify your curl/OpenSSL configuration to check memory leaks.** | ||||||||||||
|
|
||||||||||||
| ## Quick Start | ||||||||||||
|
|
||||||||||||
| ```bash | ||||||||||||
| cd memory-verifier | ||||||||||||
|
||||||||||||
| cd memory-verifier | |
| cd leaktestapp |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README references a different directory name (memory-verifier/) and a script named run_dynamic_analysis.sh, but the repo path here is leaktestapp/ and the script added is run_gdb_dynamic_analysis.sh. Update the README commands/paths to match the actual layout and filenames so the quick-start instructions work.
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Markdown code fences for “Directory Structure” / “Build & Run” appear unbalanced (a ``` block opens at “Directory Structure” but isn’t closed before “Build & Run”). This causes rendering issues on GitHub. Please close/open code fences appropriately.
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example T2_CONNECTION_POOL_SIZE=2 ./memory_verifier --pool is annotated as “Pool size 3”, which is inconsistent with the env var value. Please fix the comment/example so users don’t misconfigure the pool size.
| T2_CONNECTION_POOL_SIZE=2 ./memory_verifier --pool # Pool size 3 | |
| T2_CONNECTION_POOL_SIZE=2 ./memory_verifier --pool # Pool size 2 |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README documents dynamic_analysis.log / dynamic_analysis_summary.log outputs, but the script currently produces timestamped files under dynamic_analysis_results/ with different names. Align the README’s “Log Files & Outputs” section with the actual filenames produced (or change the script to match the documented names).
| - `dynamic_analysis.log`: Main log for run_dynamic_analysis.sh (GDB/SSL trace summary) | |
| - `dynamic_analysis_summary.log`: High-level summary of dynamic analysis results | |
| - `dynamic_analysis_results/`: Directory containing logs produced by `run_dynamic_analysis.sh`. Each run creates timestamped files, for example: | |
| - `dynamic_analysis_YYYYMMDD_HHMMSS.log`: Main log for `run_dynamic_analysis.sh` (GDB/SSL trace summary) | |
| - `dynamic_analysis_summary_YYYYMMDD_HHMMSS.log`: High-level summary of dynamic analysis results |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| === 1. GDB Call Stack Analysis === | ||
| Running GDB dynamic analysis using gdb_batch_script.gdb... | ||
| Setting 30-second timeout with 50 iterations... | ||
| Setting T2_TEST_ITERATIONS=50 for this test... | ||
| ✅ GDB analysis completed normally | ||
| === Dynamic Analysis Summary === | ||
| Analysis completed at: Wed Mar 11 01:01:09 PM EDT 2026 | ||
|
|
||
| 📁 Generated Files: | ||
| -rw-r--r-- 1 root root 336 Mar 11 13:01 dynamic_analysis_results/dynamic_ssl_20260311_130038_analysis.log | ||
| -rw-r--r-- 1 root root 492202 Mar 11 13:01 dynamic_analysis_results/dynamic_ssl_20260311_130038_gdb_trace.log | ||
|
|
||
| 📊 Quick Analysis: | ||
| === ALLOCATION ANALYSIS === | ||
| EVP_CIPHER_fetch calls: 2 | ||
| CRYPTO allocation calls: 6456 | ||
| RAND_get0_primary calls: 2 | ||
| === DEALLOCATION ANALYSIS === | ||
| CRYPTO_free calls: 2242 | ||
| EVP_CIPHER_free calls: 2 | ||
| SSL_CTX_free calls: 2 | ||
| === MEMORY LEAK ASSESSMENT === | ||
| ⚠️ POTENTIAL LEAK: 4212 more allocations than deallocations | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Makefile help suggests CLI options (
--valgrind-reset,--post-analysis) thatmemory_verifierdoesn’t currently implement/parse. Please keep Makefile help aligned with actual supported options, otherwise users will hit “Unknown argument”.