8000 Merge pull request #39 from Shopify/flavorjones-support-valgrind · jamatthews/ruby@b024ae0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b024ae0

Browse files
authored
Merge pull request ruby#39 from Shopify/flavorjones-support-valgrind
ujit_asm: if mmap() fails with the address hint, try without
2 parents 1ae750f + ef30c26 commit b024ae0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ujit_asm.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,19 @@ uint8_t* alloc_exec_mem(uint32_t mem_size)
137137
0
138138
);
139139

140+
if (mem_block == MAP_FAILED) {
141+
mem_block = (uint8_t*)mmap(
142+
NULL, // try again without the address hint (e.g., valgrind)
143+
mem_size,
144+
PROT_READ | PROT_WRITE | PROT_EXEC,
145+
MAP_PRIVATE | MAP_ANONYMOUS,
146+
-1,
147+
0
148+
);
149+
}
150+
140151
// Check that the memory mapping was successful
141-
if (mem_block == MAP_FAILED)
142-
{
152+
if (mem_block == MAP_FAILED) {
143153
fprintf(stderr, "mmap call failed\n");
144154
exit(-1);
145155
}

0 commit comments

Comments
 (0)
0