1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ujit_asm: if mmap() fails with the address hint, try without

valgrind doesn't seem to support the address hint, and so the fallback
to using NULL will allow valgrind to run.
This commit is contained in:
Mike Dalessio 2021-02-11 12:13:14 -05:00 committed by Alan Wu
parent 05d36f31ca
commit 7a75e9bbaf

View file

@ -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);
}