rrthomas / recode

Charset converter tool and library
GNU General Public License v3.0
130 stars 12 forks source link

“Too many open files” when low open file ulimit #40

Closed kugland closed 1 year ago

kugland commented 1 year ago

Recode fails with Too many open files when given more files than the soft limit on open file descriptors. Isn’t it possible to close the descriptors after recoding each file?

% ulimit -Sn 100
% seq 1 100 | xargs touch
% recode latin1..utf8 *   
pipe (): Too many open files
zsh: segmentation fault (core dumped)  recode latin1..utf8 *

Memory usage increases monotonically when recoding thousands of files because of this.

rrthomas commented 1 year ago

Thanks for this report; I'll make a new release shortly.

kugland commented 1 year ago

@rrthomas, why did this cause a segmentation fault?

Isn’t the task continuing after the call to pipe() fails?

https://github.com/rrthomas/recode/blob/de974299ccc9f69a829e22fb53c37403a7bb942d/src/task.c#L299-L310

rrthomas commented 1 year ago

This is a good question, I was wondering myself. In fact, recode crashes while trying to output an error message; I'll look into it!

rrthomas commented 1 year ago

I have fixed this bug; thanks!