jacereda / fsatrace

Filesystem access tracer
ISC License
81 stars 12 forks source link

Switch from recursion to iteration for uniq() #38

Closed nehaljwani closed 4 years ago

nehaljwani commented 4 years ago

As the number of unique files accessed grow in number, the recursive implementation of uniq() can lead to a segfault because of stack size limitations. One can work around this by increasing the stack size limit (ulimit -s), however that is not always possible.

This commit changes the implementation of uniq() to use iteration so that such limits do not lead to problems.

jacereda commented 4 years ago

Thanks for the PR. The implementation of uniq is tail-recursive, so the reason for the crash is the fact that I messed the compilation flags recently and accidentally left them at -O0 level.

nehaljwani commented 4 years ago

Thank you for reminding me about that concept!