Skip to content

Commit

Permalink
Merge pull request #39 from Shopify/flavorjones-support-valgrind
Browse files Browse the repository at this point in the history
ujit_asm: if mmap() fails with the address hint, try without
  • Loading branch information
maximecb committed Feb 11, 2021
2 parents 1ae750f + ef30c26 commit b024ae0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ujit_asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,19 @@ uint8_t* alloc_exec_mem(uint32_t mem_size)
0
);

if (mem_block == MAP_FAILED) {
mem_block = (uint8_t*)mmap(
NULL, // try again without the address hint (e.g., valgrind)
mem_size,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0
);
}

// Check that the memory mapping was successful
if (mem_block == MAP_FAILED)
{
if (mem_block == MAP_FAILED) {
fprintf(stderr, "mmap call failed\n");
exit(-1);
}
Expand Down

0 comments on commit b024ae0

Please sign in to comment.