-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
CSVLint causes Notepad++ crash when attempting to open file with more than 2**31 - 1 bytes #93
Comments
Update scripts to generate 2GB of random data for testing issue #93
Thanks for posting the issue. I think Notepad++ runs into other issues as well when opening such large >2GB files. I'll look into this when I have the time. For now, I've updated the generate_data.py script to generate a |
I decided to take a crack at solving this problem myself, and this commit is the result. There are a fair number of lines of code changed, but the basic idea is quite simple: check for file length before creating a StreamReader, and (optionally) notify the user if the file was too long. Because One thing to note: I didn't actually test the code as it was committed; rather, I tested it all with You may feel that this is too much code, and I'd be very open to suggestions for improvement, but as far as I can tell it's just about the smallest change that would be sufficient to eliminate all possibility of crashes on too-large files. |
@molsonkiko Thanks for looking into this issue 👏 I've looked over the changes and it looks good to me. Could you submit the PR? I'll it test some more and put it into a new release when I have the time. (btw I know you looked at it before, but do you maybe also have a clue how to solve the transparent cursor line interfering with the ComparePlus? See #68 ) |
#94 should address this issue. I added a couple more commits to ensure that all plugin commands warn the user if the file is too large, rather than failing silently. With regards to #68, I still don't understand the underlying issues (in your plugin or ComparePlus), but I may take a crack at it at some point in the future. |
To replicate
int.MaxValue
).Expected behavior
Obviously I expect no crash. I would also expect CSVLint to explain to the user that the file is too large for CSVLint to open whenever they manually run a plugin command.
Debug info
Proposed solution
The sneaky problem with the plugin infrastructure we use is that you can't even attempt to get the length of a file with length greater than
int.MaxValue
if theISCintillaGateway.GetLength()
method returns anint
. The obvious solution is to have the method return along
, but it's annoying to do bounds checking on thelong
every time, so the best solution is to have a helper method.I'm not going to submit a PR because I don't have the .NET Framework 4.0 targeting pack installed and I don't feel like installing it, but you can see how I changed JsonTools to fix this issue.
In short, you want to do the following:
ScintillaGateway
andIScintillaGateway
so that theGetLength()
method returns along
:Main
class that does the bounds checking and (optionally) warns the user if the file is too big:The text was updated successfully, but these errors were encountered: