Skip to content

Fixed tcg temp alloc without free in mips tcg translation#2305

Open
justdaniel-gh wants to merge 1 commit intounicorn-engine:devfrom
justdaniel-gh:fix-2240-mips-tcg-alloc-without-free
Open

Fixed tcg temp alloc without free in mips tcg translation#2305
justdaniel-gh wants to merge 1 commit intounicorn-engine:devfrom
justdaniel-gh:fix-2240-mips-tcg-alloc-without-free

Conversation

@justdaniel-gh
Copy link

@justdaniel-gh justdaniel-gh commented Mar 5, 2026

Fixes #2240

Calls to tcg_const_i32 end up calling tcg_temp_alloc (in tcg.c:tcg_temp_new_internal), which allocates a temp var in ctx->temps[]. tcg_temp_free_i32 should be called to free the allocated temp var.

Without it, ctx->temps will eventually overflow ctx->ops and SEGFAULT.

// Map a page of NOPs (0x00); exercises a potential for a bug when a TB contains
// more instructions than temp slots (if temp tcg vars are not freed)
uc_mem_map(uc, base, 0x1000, UC_PROT_READ | UC_PROT_EXEC | UC_PROT_WRITE);
uc_ctl_request_cache(uc, base, &tb);
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also use OK() for the other two uc calls and add a OK(uc_close(uc))

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.

2 participants