**[using arm-hisiv300-linux-gcc to compile for Linux based Target board]**

I got segmentation fault while I called this function.

```
uint32_t dir_disp(void)
{
    uint32_t        err;
    uint32_t        i;
    size_t          cnt;
    char            *str;
    char            **p;

    glob_t          glob_results;   

    err = glob("/home/2019-11-12/H*", GLOB_MARK, 0, &glob_results);

    p = glob_results.gl_pathv;
    cnt = glob_results.gl_pathc;

    for (i=0; i<cnt; i++)
    {
        printf("[DEBUG] dir_disp: %s\n",p[i]);
    }

    globfree(&glob_results);
    return 0;
}

```

the above function is called only once from a **thread function**, the segmentation fault occurred only when there are more than ~100 items matching the pattern "`/home/2019-11-12/H*`"

Segmentation fault doesn't occur if:

* less than ~100 items matching the pattern
* or comment out the printf in for loop
* or comment out globfree()
* or call the function in another program without thread

[Edit]

Sorry but I forgot to mention the segfault occur only after printing all the items matching the pattern.

I checked the ret val of `glob()` and found it to be zero. Not changing the original question.