-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Bug in buffer handling in readlines() function for \r\n new line type #22430
Comments
Here is a minimal working example catching the problem (and it can be simply changed to a test set covering all possibilities of end line types and positions):
It is probably caused by the code starting in this line: Line 257 in 96b28d6
when \r is a last character in a buffer at position IOS_BUFSIZE .
|
@nalimilan Unfortunately no as I have no experience with modifying C sources of Julia. |
There's a first time for everything 😀 |
I can tell you what I guess is wrong and how it could be fixed, but I do not feel qualified enough to make a PR. What is probably wrong: The simplest fix would be to after this line (but I am not sure how to safely do it without risk of breaking something else): |
If I understand it correctly
from:
to (assuming
Unfortunately I am unable to test it (I have failed to successfully build Julia head under Win and under Ubuntu). @pszufe Could you try checking this proposal? |
@bkamins If you think that fix would work, you can make a pull request without building Julia locally, adding new test that would previously fail, and see whether the build and tests pass on Travis and AppVeyor. In general that's a risky strategy (the build may fail just because you forgot to add a parenthesis), but for localized fixes like this it could be OK. Are you sure your proposal won't hurt performance, though? Not saying it will, but that's something to consider. |
I was working it out in my head so I do not want to make a push (yesterday I made a small proposal #22496 without properly running all checks and I had to correct it). I have talked with @pszufe and he told me that he would help to setup a proper environment and test the correctness and performance. I believe that performance should not be degraded as there are only two assignments to |
Does #22621 seem acceptable? |
Closed in #22621 |
There some buffering error in how windows new line characters are being handled by the
readlines()
function.Please consider the following code:
And the output:
Seems like improper handling of the last character in the buffer.
Tested on Julia 0.6.0-rc3 and 0.7.0-DEV.636
The text was updated successfully, but these errors were encountered: