Whenever I try to access the 3rd element or higher of this 2d array, i keep getting segfaults because apparently i havnt allocated any memory there... but I have.

Code:
typedef struct {
    char ***array1
    char ***array2
} info;

void *thread(void *arg) {
    info b;
    b = *(info *)arg;
    ...
    sscanf(buffer, "%s", *b.array1[pthread_self()-2]);
    ...
}
     

function {
    ...
    char **x = (char **)malloc(sizeof(char*)*10);
    char **y = (char **)malloc(sizeof(char*)*10);
    for (i=0;i<10;i++) {
        x[i] = (char*)malloc(sizeof(char)*50);
        y[i] = (char*)malloc(sizeof(char)*60);
    }
    info a;
    a.array1 = &x;
    a.array2 = &y;
    while(1) {
        ...
        pthread_create(&tid,NULL,thread, (void *)&a);
        pthread_join(tid, NULL);
    }
}
I just put in the code that was relevant to the problem. When pthread_self() becomes 4 or greater, I get a segfault because of memory access (thats what gdb says).

This is on unix/linux btw. I don't know if that would limit the number of people being able to help me with this.