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

Work on removing global static initializers #3943

Open
Sonicadvance1 opened this issue Aug 11, 2024 · 0 comments
Open

Work on removing global static initializers #3943

Sonicadvance1 opened this issue Aug 11, 2024 · 0 comments

Comments

@Sonicadvance1
Copy link
Member

Sonicadvance1 commented Aug 11, 2024

Global static initializers have problems under FEX. They have a couple of problems, mostly centered around memory allocation

  • They can allocate untracked memory upfront that FEX can't control.
    • This means it has memory originally allocated through jemalloc before the allocation hooks are setup
  • They can register atexit handlers that can crash on application close
    • This is used to cleanup the memory allocated before FEX can track it

FEX currently works around these previous problems by leaking all memory allocated on process shutdown and letting the kernel clean it up.

A major issue that occurs is when the static initializer allocates memory pre-hook, then once the hooks are installed, it allocates new memory through the FEX hooks, having a mix of pre-hook and post-hook memory allocations. On munmap this tracking will get confused and leak memory.

In the case of mixed-allocation and /not/ leaking, it can result in a crash but it's been a couple years since we enabled the leaking, so I don't quite remember why the crashes come.

From the on and off work over the past few years, we have removed most static initializers but there are still a handful sprinkled throughout the FEX codebase.

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