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

double-free after running 2 games #32

Open
hizzlekizzle opened this issue Jun 29, 2023 · 1 comment · May be fixed by #34
Open

double-free after running 2 games #32

hizzlekizzle opened this issue Jun 29, 2023 · 1 comment · May be fixed by #34

Comments

@hizzlekizzle
Copy link

hizzlekizzle commented Jun 29, 2023

For whatever reason, this isn't (apparently) a problem in RetroArch but crashes in BizHawk and presumably other frontends.

free(my_av_info);

struct retro_system_av_info *my_av_info = (retro_system_av_info*)malloc(sizeof(*my_av_info));

my_av_info gets malloc'd once on program init (although not in retro_init), then when retro_unload_game is called it gets free'd... and since it's never malloc'd again a subseqent retro_unload_game call causes it to free that pointer again which expectingly crashes.

So, presumably my_av_info doesn't need to be free'd until deinit instead of in retro_unload_game...?

original issue from BizHawk's repo: TASEmulators/BizHawk#3250

@keithbowes
Copy link
Contributor

Why it doesn't crash in RetroArch is surely pure luck (perhaps RetroArch doesn't call retro_unload_game, which is surely a bug). The core allocates my_av_info globally but then frees it locally; whether free should be in retro_unload_game or retro_deinit is fairly a moot point; allocating my_av_info should be in retro_load_game or retro_init (depending on where free is).

keithbowes added a commit to keithbowes/tgbdual-libretro that referenced this issue Jul 5, 2024
@keithbowes keithbowes linked a pull request Jul 5, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants