New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault on MacBook M1 due to unlimited file descriptors #63
Comments
|
Thanks for reporting this; I'm surprised because my older MacBook Air running 11.1 reports more reasonable limits #include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
int main() {
struct rlimit rl;
getrlimit(RLIMIT_NOFILE, &rl);
printf("rlim_cur: %lu\n", (unsigned long)rl.rlim_cur);
printf("rlim_max: %lu\n", (unsigned long)rl.rlim_max);
printf("_SC_OPEN_MAX: %lu\n", (unsigned long)sysconf(_SC_OPEN_MAX));
} |
|
Yeah, I'm not sure why I have this unlimited by default. Of course I can configure it to make it work. The actual problem in the code is this line:
|
|
@badboy: please build and run this test program and tell me what the output is? I wonder if #include <stdio.h>
#include <unistd.h>
#include <err.h>
int main() {
long open_max;
open_max = sysconf(_SC_OPEN_MAX);
if (open_max == -1)
err(1, "_SC_OPEN_MAX");
else
printf("_SC_OPEN_MAX: %lu\n", (unsigned long)open_max);
} |
Nope, From some peopel I asked it seems their M1 machines all have |
|
Fascinating... it really is returning Agreed; regardless of why this value is set, |
|
Seems reasonable to me. |
|
I pushed commit 8f224fb to address this. I picked a hard limit of 524288 somewhat arbitrarily, since this is the normal hard limit I see on MacOS 11.1 |
|
👍 works for me. |
|
This fix was included in the 4.8 release today |
I get segmentation faults with the latest version of entr (4.7 or git checkout).
This happens on a MacBook M1 (Arm chip), running macOS Big Sur, not much changed from the default configuration.
Backtrace:
I added some logging:
n_fileshere is 0.max_filesis-1.After
getrlimit(RLIMIT_NOFILE) I get:that.
That'sThat'sUINT64_MAXINT64_MAX.sysconf(_SC_OPEN_MAX)also returns that.As
rlim_curis the minimum out of all of that it'sINT64_MAXbefore being passed toprocess_input. Nowprocess_inputtakes an int, so it's coerced and becomes-1.Seems my file descriptors are unlimited by default:
Changing it to some more reasonable low number makes
entrwork as expected:Question:
entrenforce a more reasonable limit for this case?process_filemaybe not use a different integer type than the one passed in?The text was updated successfully, but these errors were encountered: