Skip to content

update libretro headers; platform-specific memory tweaks - #2423

Open
warmenhoven wants to merge 2 commits into
flyinghead:devfrom
warmenhoven:warmenhoven/pr/libretro
Open

update libretro headers; platform-specific memory tweaks#2423
warmenhoven wants to merge 2 commits into
flyinghead:devfrom
warmenhoven:warmenhoven/pr/libretro

Conversation

@warmenhoven

Copy link
Copy Markdown
Contributor

No description provided.

@warmenhoven
warmenhoven force-pushed the warmenhoven/pr/libretro branch from 4f12942 to dd78418 Compare August 1, 2026 02:19
@warmenhoven

Copy link
Copy Markdown
Contributor Author

@flyinghead

Copy link
Copy Markdown
Owner

Please target the dev branch since some changes affect more than just libretro.

@warmenhoven
warmenhoven changed the base branch from master to dev August 1, 2026 17:20
@warmenhoven

Copy link
Copy Markdown
Contributor Author

Sure, done. Let me know if you want me to remove the translation commit that got pulled in as well?

@flyinghead

Copy link
Copy Markdown
Owner

That's fine. Thanks

@flyinghead
flyinghead requested a review from vkedwardli August 2, 2026 16:37
@vkedwardli

Copy link
Copy Markdown
Collaborator

Job has been erased by m4xw 2 days ago

Sorry seems I'm a bit late so I can't download the iOS binary and test

I noticed that

/**
 * Parameters for \c RETRO_ENVIRONMENT_EXEC_MEM_FREE.
 * @see RETRO_ENVIRONMENT_EXEC_MEM_FREE
 */
struct retro_exec_mem_free
{
   void *rx;  /**< The \c rx pointer returned by a previous alloc call. */
};

but in our Flycast implementation using dsp as example:

void recTerm()
{
#if defined(TARGET_IPHONE) || defined(TARGET_ARM_MAC)
	DynCode = nullptr;
#endif
#ifdef FEAT_NO_RWX_PAGES
	if (pCodeBuffer != nullptr)
		virtmem::release_jit_block(DynCode, pCodeBuffer, CodeSize);

so it would mean

void release_jit_block(void *code_area1, void *code_area2, size_t size)
{
	if (free_via_frontend(nullptr) || free_via_frontend(pCodeBuffer))
		return;
	munmap(pCodeBuffer, CodeSize);
}

In the DSP RETRO_EXEC_MEM_MODE_DUAL_MAP path, pCodeBuffer contains alloc.rw, while DynCode contains alloc.rx

So we are passing Rw pointer into free_via_frontend and if it returns false (since that function could expect we pass Rx?), then Flycast is calling munmap directly which the memory is not owned by Flycast

Current RetroArch should accept either the RX or RW pointer, so I guess this is working, but is this a problem if other frontends that cannot handle the Rw pointer (since the header API is Rx), return false, Flycast would then call munmap() on frontend-provided memory?

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 this pull request may close these issues.

3 participants