-
Notifications
You must be signed in to change notification settings - Fork 17
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
mmap: String access is truncated or causes NullPointerException #28
Comments
Thanks for reporting this issue. However, a copy/paste-able form would have been convenient for reproduction, so I'll share it here:
Added a length output, which at least yields the correct value. |
I just tried it with some text file and there it works fine. Seems to be unrelated to newline characters.
So, this seems to depend somehow on file content. |
Thanks for your help. I think the problem is due to \x00. i have changed the function JySync_Init_JyString_From_PyString in JyNI-C/JySync.c . it seems to work fine. this is my change.
|
But the crash still appears.
|
Okay, these seem to be two separate things. The idea to fix it in For the |
I modified the way to get the length of C string when it was converted to jstring. In the previous way, when the string of C was converted to jstring, the string was truncated because of \x00. Modifying the encoding method to GB2312 does not solve the problem of string truncation. The code is copied from the network, and the original code is GB2312 encoded. I found that the code can take effect so it doesn't change. I have the same results for utf8. |
Oh, okay
can be removed because in JyNI these IDs are already cached at startup. I suggest this implementation:
We should move |
@Stewori Did you analyze the cause of NullPointerException? I couldn't find the reason. |
Sorry, this is currently in conflict with my work on #22 in my local branch, causing additional errors. Sure, I could make a second clone for this, but anyway -- I prefer to work on one issue at a time. Given that #22 is tricky, it might take a while until I can follow up here. So far it's limited to rough comments, review and style hints, e.t.c. from my side. |
Did you check that the conversion matches CPython behavior? With that taken into account, would you turn your fix into a PR? If you would turn it into a PR, these two lines should be adjusted to fit with JyNI's approach to handle JNI:
The first lookup can be avoided by directly using Otherwise I can refactor it into a commit as soon as I find time. |
In the first pic, i used mmap to read file with python. the second is jython and JyNI. the string is truncated when i used JyNI.
The text was updated successfully, but these errors were encountered: