plasma-umass / Mesh

A memory allocator that automatically reduces the memory footprint of C/C++ applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Abort in mesh::MiniHeap::spanStart - spanStartSlowPath

cake4289 opened this issue · comments

The following code causes an abort

#include <stdlib.h>

#define COUNT 10000000
#define SIZE 1024

int main(void) {
    int i;
    void **mem = malloc(COUNT * sizeof(void*));
    for (i = 0; i < COUNT; i++) {
        mem[i] = malloc(SIZE);
    }
    for (i = COUNT-1; i >= 0; i--) {
        free(mem[i]);
    }
    free(mem);
    while (1);
}

Backtrace:

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff76b7801 in __GI_abort () at abort.c:79
#2  0x00007ffff7ae8605 in spanStartSlowpath (this=this@entry=0x7fffcf8ae000, arenaBegin=140728068661248, ptrval=ptrval@entry=140728085438464) at src/mini_heap.h:442
#3  0x00007ffff7aed81b in mesh::MiniHeap::spanStart(unsigned long, void*) const () at src/mini_heap.h:432
#4  mesh::MiniHeap::getOff(void const*, void*) const () at src/mini_heap.h:405
#5  mesh::MiniHeap::free(void*, void*) () at src/mini_heap.h:166
#6  freeFor (this=0x7ffff7dcb320 <mesh::runtime()::buf>, mh=<optimized out>, ptr=0x7ffdcf8ae000) at src/global_heap.cc:79
#7  0x0000555555554717 in main () at vd.c:15

I am running Ubuntu 18.04:

Linux 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

great find! this is almost certainly due to allocating more than 8 GB of objects, which is configured here: https://github.com/plasma-umass/Mesh/blob/master/src/common.h#L97

I think we can safely just bump that up. It was low because our current approach of mmap'ing a large sparse mapping causes the kernel to coredump the entire mapping, turning it from a sparse mapping to one with a bunch of zeros.

I will look at fixing this later today

@cake4289 I merged a fix that will give a sensical error message for this problem:

XPS 08:51:03 (master) [bpowers@aika mesh]$ LD_PRELOAD=$PWD/libmesh.so ./aborting 
Mesh: arena exhausted: current arena size is 8.0 GB; recompile with larger arena size.
Aborted (core dumped)

I'll leave this open, because I think we also want to increase the size of the arena soon, which will cause your program to start working

@cake4289 this should be resolved! thanks again for the report.