-
Notifications
You must be signed in to change notification settings - Fork 365
Fix: Memory leak in riscv_openocd_step_impl() #1303
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: riscv
Are you sure you want to change the base?
Conversation
Added additional debug logs to verify correct retrieval and printing of progbufsize in various code paths within riscv-013.c. This helps in debugging hardware configurations that expose custom program buffer sizes. Signed-off-by: Biancaa Ramesh <[email protected]>
…d-write Added a check for have_progbuf_size before attempting to execute. This prevents program buffer access on targets that do not support it, improving robustness and avoiding potential execution failures when the program buffer is not available or too small. Signed-off-by: Biancaa Ramesh <[email protected]>
Fixes a memory leak caused by wps_to_enable being allocated with calloc() and never freed. The pointer is now properly freed at the end of the function and on early error returns. This leak was originally introduced in commit 5a8697b (trigger management refactor). Signed-off-by: Biancaa Ramesh [email protected]
Signed-off-by: Biancaa Ramesh <[email protected]>
|
@Biancaa-R, thank you for the patch. Unfortunately, there is already a patch with a fix. I should have mentioned it in the issue, sorry. |
Are you referring to introducing test runs under Valgrind to the CI? |
Yes I am ,to ensure it is caught . |
Oh no worries :) |
This adds a lightweight run that: Starts OpenOCD once under Valgrind. Runs initialization and shutdown. Fails if Valgrind reports any memory leaks (via --error-exitcode=1). Signed-off-by: Biancaa Ramesh <[email protected]>
|
Ok let me check and get back. |
Signed-off-by: Biancaa Ramesh <[email protected]>
Tried to run valgrind with no dependent cfg files. Signed-off-by: Biancaa Ramesh <[email protected]>
|
If this approach also doesnt work ,I would probably : If our goal is just to check core memory management (no targets at all): valgrind --leak-check=full --error-exitcode=1 Or use a dummy config file additionally. |
|
@Biancaa-R, I'd suggest not to spend too much time on this one right now. We are currently merging RISC-V OpenOCD with the mainline and after this work is done, I'd like to stop the development in this repo, posting patches to https://review.openocd.org instead. As for what can be run under valgrind -- there is the |
cleared wps_to_enable in _exit after there is no further reference to it .

The memory allocated at :
Fixes the issue: #1284