jdetter / Chronos

The Chronos kernel
GNU General Public License v3.0
9 stars 1 forks source link

Repeated mallocs/frees causing segfault #4

Open jdetter opened 8 years ago

jdetter commented 8 years ago

This test passes on Linux, however causes a segfault in Chronos. Reproducer program (malloc test in testsuite):

#include <stdlib.h>
#include <testsuite.h>

#define COUNT 0x10000
#define ALLOC_SIZE 0x1000

int main(int argc, char** argv)
{
    int* arr[COUNT];
    int x;
    for(x = 0;x < COUNT;x++)
    {
        arr[x] = malloc(ALLOC_SIZE);
        if(!arr[x])
            TESTFAILURE;
    }

    for(x = 0;x < COUNT;x++)
        free(arr[x]);

    for(x = 0;x < COUNT;x++)
    {
        arr[x] = malloc(ALLOC_SIZE);
        if(!arr[x])
            TESTFAILURE;
    }

    for(x = 0;x < COUNT;x++)
        free(arr[x]);

    TESTSUCCESS;

    return 0;
}
jdetter commented 8 years ago

Lowering count from 0x10000 to 0x1000 passes. Could be issue with sbrk or brk (whichever is being used).