Skip to content
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

Get next line - very large fd #129

Open
KalindiFonda opened this issue Dec 1, 2018 · 5 comments
Open

Get next line - very large fd #129

KalindiFonda opened this issue Dec 1, 2018 · 5 comments

Comments

@KalindiFonda
Copy link

if one implements gnl by using a mx_fd option, a very large fd causes a seg fault.

@jgigault
Copy link
Owner

Hello @KalindiFonda
Can you please provide me an example of that implementation?

@KalindiFonda
Copy link
Author

Hi, my code failed when moulinette used a very large fd, and that is because of the way I set my static variable - as it depends on a number (MAX_FD_N) I give it.
static char *r_str[MAX_FD_N];

Would it be useful for you to see my code?

@jgigault
Copy link
Owner

Yes, for sure I am interested in look at your code.
It would be nice if you provide me a full example of the issue: a large file and your main.c?

@tobyhw
Copy link

tobyhw commented Mar 7, 2019

The issue here is not a large file but a large fd.

I have seen implementations like this where essentially a large array of string pointers is initiated as a static variable and accessed simply using r_str[fd] when called.

The problem is that if too many files are open, the fd may be greater than MAX_FD_N. If this value is large enough, you will not have an error (which should be a bus error and not a segfault), but then you're using about 80MB of memory for no reason. It would be interesting to add this test as I have seen a lot of implementations lately that take this (highly inefficient) shortcut

@jgigault
Copy link
Owner

Hello @tobyhw
How would you handle tests for that issue?
Should we open file descriptors with gnl with huge number of iterations? How many iterations? How to determine when the test is relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants