Skip to content

Comments

Fix asm tokens leaking horrendously because they used Vector and PVector#5019

Merged
notxvilka merged 12 commits intorizinorg:devfrom
Rot127:asm-toks-leaks
Mar 31, 2025
Merged

Fix asm tokens leaking horrendously because they used Vector and PVector#5019
notxvilka merged 12 commits intorizinorg:devfrom
Rot127:asm-toks-leaks

Conversation

@Rot127
Copy link
Member

@Rot127 Rot127 commented Mar 20, 2025

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository.
  • I made sure to follow the project's coding style.
  • I've documented every RZ_API function and struct this PR changes.
  • I've added tests that prove my changes are effective (required for changes to RZ_API).
  • I've updated the Rizin book with the relevant information (if needed).

Detailed description

I must have missed some places back then, when converting to pvector. And it leaked like there is no tomorrow.
This should fix it now.

#5015 is still valid, but I probably ran the wrong build (without LSAN). Hence thought it fixed it.

Test plan

All green

Closing issues

...

@Rot127
Copy link
Member Author

Rot127 commented Mar 20, 2025

Still missed some somewhere.

@Rot127 Rot127 marked this pull request as draft March 20, 2025 15:51
@Rot127 Rot127 marked this pull request as ready for review March 24, 2025 17:33
notxvilka

This comment was marked as resolved.

Copy link
Contributor

@notxvilka notxvilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The only doubt I have is that _free() function in the _init()

Copy link
Member

@wargio wargio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong

@Rot127 Rot127 requested review from notxvilka and wargio March 30, 2025 10:57
Copy link
Contributor

@notxvilka notxvilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach is certainly better!

@notxvilka
Copy link
Contributor

@wargio take a look again please

Rot127 added 12 commits March 30, 2025 16:32
The RzAsmOp passed here could be a previously initialized one.
With allocated asm_tokens. Doing memset just leaks those tokens.
In practice rz_asm_op_init() is the best place to free the asm_toks reliably.
Simply because this is always called in the old code, before an instruction is disassembled.
Only in fini() is not enough, because there are too many place it is not called, leaking the tokens.
@notxvilka notxvilka merged commit 99efcb6 into rizinorg:dev Mar 31, 2025
45 checks passed
@Rot127 Rot127 deleted the asm-toks-leaks branch March 31, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants