Skip to content
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

EDmac module can leak significant amounts of mem #124

Open
reticulatedpines opened this issue Dec 26, 2023 · 0 comments
Open

EDmac module can leak significant amounts of mem #124

reticulatedpines opened this issue Dec 26, 2023 · 0 comments

Comments

@reticulatedpines
Copy link
Owner

reticulatedpines commented Dec 26, 2023

CreateResLockEntry() returns LockEntry *. modules/edmac/edmac.c can do this in a loop due to find_free_edmac_channels(), and never frees it.

LockEntry has pResources that is also allocated inside CreateResLockEntry(), of variable size (although fixed and small in the case of find_free_edmac_channels()). Max is 32 loops, on 200D 0x28 bytes per loop, 1280 bytes max per call.

Presumably we should free pResources and the LockEntry, although I have not tested this. I think you want to Unlock before the free, to remove avoid dangling pointers in ResourceInfo_global.

Things to check:

  • is it really a leak? I believe this only due to static analysis on 200D, wants to be tested
  • is the free safe on all gens? Only checked 200D code so far
  • audit all other uses of CreateResLockEntry() (quick check suggests we never free, but maybe we only assign once so it doesn't matter, we never lose the ref)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant