1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Fix embarassing bug in which lack of MAP_FIXED meant unaligned slabs

This would manifest itself in odd failures when accessing
block/object metadata on slabs.
This commit is contained in:
Andy Wingo 2025-04-23 10:42:05 +02:00
parent 1818d7fa0b
commit 3c4fdfde0e

View file

@ -162,12 +162,12 @@ gc_platform_acquire_memory_from_reservation(struct gc_reservation reservation,
GC_ASSERT(size <= reservation.size);
GC_ASSERT(offset <= reservation.size - size);
void *mem = mmap((void*)(reservation.base + offset), size,
PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (mem == MAP_FAILED) {
perror("mmap failed");
void *mem = (void*)(reservation.base + offset);
if (mprotect(mem, size, PROT_READ|PROT_WRITE)) {
perror("mprotect failed");
return NULL;
}
// FIXME: Should we gc_platform_populate_memory() here?
return mem;
}