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

[Maiko] bus error/segmentation fault when too many versions of a file in a directory #1826

Open
nbriggs opened this issue Sep 9, 2024 · 8 comments
Assignees
Labels
bug Something isn't working (as per documentation) high priority

Comments

@nbriggs
Copy link
Contributor

nbriggs commented Sep 9, 2024

The local file code handling versioned files in Maiko smashed memory when there are more than 200 versions of a file in a directory, running unchecked off the end of a fixed size (VERSIONARRAYLENGTH) array.

  • this MUST NOT fail like this (at minimum, report an error)
  • this SHOULD dynamically allocate the storage as necessary to efficiently handle larger collections of versioned files
@nbriggs nbriggs self-assigned this Sep 9, 2024
@nbriggs nbriggs added bug Something isn't working (as per documentation) high priority labels Sep 9, 2024
@nbriggs
Copy link
Contributor Author

nbriggs commented Sep 9, 2024

@rmkaplan - first level of fix is to report an error rather than crash - this is what it would look like if it sends back an EMFILE (too many open files) system error when it encounters more than 200 versions of a file you're operating on:
Screenshot 2024-09-09 at 1 38 25 PM

Next level fix is to make it allocate storage (this is all outside Lisp memory) for the version array as required.

@rmkaplan
Copy link
Contributor

rmkaplan commented Sep 9, 2024 via email

@nbriggs
Copy link
Contributor Author

nbriggs commented Sep 9, 2024

There's no UNIX error that talks about versions -- and all we get to pass up at this point is a Unix error number -- do man errno and tell me if one of those says something you think is more appropriate (EMFILE was the one I chose)

@rmkaplan
Copy link
Contributor

rmkaplan commented Sep 9, 2024 via email

@nbriggs
Copy link
Contributor Author

nbriggs commented Sep 9, 2024

Yeah, I know that it's not actually open files, it's trying to do certain operations on a file that has over 200 distinct versions, which causes it to enumerate those versions and attempt to store them in an array that is too small. Please look at the output of man errno in a terminal window and see if you see anything you'd be more comfortable with (e.g., I could go more generic and use EIO "INPUT/OUTPUT ERROR") -- but in the longer term, I think I will be able to just fix the problem of static array allocation.

@rmkaplan
Copy link
Contributor

rmkaplan commented Sep 10, 2024 via email

@nbriggs
Copy link
Contributor Author

nbriggs commented Sep 11, 2024

Using EIO results in a SIMPLE-DEVICE-ERROR being thrown. That should be catchable -- BUT, after this initial fix gets merged I'm going to rewrite a bunch of the code in there so that it will be extremely unlikely to happen again (I think you'd need millions of versions of a file to provoke it)

@nbriggs
Copy link
Contributor Author

nbriggs commented Sep 17, 2024

Closed by PR Interlisp/maiko#512

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working (as per documentation) high priority
Projects
None yet
Development

No branches or pull requests

2 participants