Skip to content

Commit

Permalink
Fix alignment of nursery allocations
Browse files Browse the repository at this point in the history
Recent changes used a path to nursery allocation that are not aligned,
leading to segfaults on e.g. armhf. Alignment is really a property of
the nursery as it is also encoded in the collector, so doing the
alignment within the allocator, not at the call site.

Fixes MoarVM#951
  • Loading branch information
Robert Lemmen committed Sep 13, 2018
1 parent 1d68871 commit 0a377ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/gc/allocation.c
Expand Up @@ -9,6 +9,9 @@
* trigger a GC run if there is not enough. */
void * MVM_gc_allocate_nursery(MVMThreadContext *tc, size_t size) {
void *allocated;
/* objects in the nursery must be aligned, so we pad at the end. The
* assumption that they are aligned is also encoded in the collector */
size = MVM_ALIGN_SIZE(size);

/* Before an allocation is a GC safe-point and thus a good GC sync point
* also; check if we've been signalled to collect. */
Expand Down
2 changes: 1 addition & 1 deletion src/gc/allocation.h
Expand Up @@ -15,5 +15,5 @@ void MVM_gc_allocate_gen2_default_clear(MVMThreadContext *tc);
MVM_STATIC_INLINE void * MVM_gc_allocate(MVMThreadContext *tc, size_t size) {
return tc->allocate_in_gen2
? MVM_gc_gen2_allocate_zeroed(tc->gen2, size)
: MVM_gc_allocate_nursery(tc, MVM_ALIGN_SIZE(size));
: MVM_gc_allocate_nursery(tc, size);
}

0 comments on commit 0a377ed

Please sign in to comment.