-
-
Notifications
You must be signed in to change notification settings - Fork 499
test: fix ASan-detected memory leaks in mark API tests #5785
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: dev
Are you sure you want to change the base?
Conversation
80713da to
2ba9d69
Compare
|
Thanks for pointing that out. |
Rot127
left a comment
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.
Tests don't pass
| char *tb = rz_sys_getenv("RZ_TESTBINS"); | ||
| mu_assert_notnull(tb, "RZ_TESTBINS not set"); | ||
|
|
||
| char *path = rz_str_newf("%s/elf/emulateme.arm64", tb); | ||
| rz_mem_free(tb); | ||
| RzCoreFile *cf = rz_core_file_open(core, path, RZ_PERM_RWX, 0); | ||
| rz_mem_free(path); |
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.
did you run this code? seems AI generated
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.
Yes, I ran this locally under ASan. You're right about rz_sys_getenv, I treated it as owned, which was wrong.
I'll fix the ownership and update the PR.
Your checklist for this pull request
RZ_APIfunction and struct this PR changes.Detailed description
LeakSanitizer was reporting leaks in the mark unit tests when running
test_rz_mark_get_all_off()andtest_rz_mark_all_list().Both functions return owned
RzListobjects, but the tests were not freeing them, which caused the leaks. This change updates the tests to release those lists properly so ASan runs are clean.Also fixes a memory leak in
test_analysis_ilwhere the value returned byrz_sys_getenv()was not freed.Test plan
Built and tested using AddressSanitizer:
meson setup build-asan -Db_sanitize=address,undefined
ninja -C build-asan
ASAN_OPTIONS=abort_on_error=1:print_stacktrace=1
UBSAN_OPTIONS=abort_on_error=1:print_stacktrace=1
./build-asan/test/unit/test_marks
Output after the fix:
test_rz_mark_get_at OK
test_rz_mark_get_all_off OK
test_rz_mark_all_list OK
test_rz_mark_unset OK
test_rz_mark_set_properties OK
test_rz_mark_rename OK
test_rz_mark_count_and_starts_or_ends OK
No ASan/LSan errors reported.
test/integration/test_analysis_il also passes cleanly under ASan.
Closing issues