On 8/7/20 3:16 AM, Xiaoming Ni wrote: > Realpath() cyclically invokes __alloca() when processing soft link files, > which may consume 164 KB stack space. > Therefore, replace __alloca with malloc to reduce stack overflow risks I don't understand why malloc is required here. Isn't the problem that the buffer is being allocated over and over again? And if you fix that bug, the function should allocate only 8 KiB via __alloca on GNU/Linux. Something like the attached (untested) patch, say. So why not keep using the stack? That would be more efficient than resorting to the heap.