Uh oh!
There was an error while loading. Please reload this page.
Fix memory corruption with FFI backend - #180
Merged
Merged
Conversation
ankaneforce-pushed
the
ffi-backend-corruption
branch
from
April 21, 2025 01:46
2b8e414 to
07a606fComparekou
reviewed
Apr 21, 2025
Comment on lines
242
to
243
| cptr = Pointer.malloc(value.bytesize + 1) | ||
| cptr.ffi_ptr.put_string(0, value) |
Member
There was a problem hiding this comment.
We may need to use put_bytes instead...
Suggested change
| cptr=Pointer.malloc(value.bytesize + 1) | |
| cptr.ffi_ptr.put_string(0,value) | |
| cptr=Pointer.malloc(value.bytesize) | |
| cptr.ffi_ptr.put_bytes(0,value) |
ContributorAuthor
There was a problem hiding this comment.
Tried that initially with write_bytes, but looks like some of the tests expect an additional null byte.
ContributorAuthor
There was a problem hiding this comment.
Nevermind, looks like the failing tests are due to an issue with the to_s method.
Member
There was a problem hiding this comment.
@kou Is it expected though that Fiddle::Pointer.to_ptr("abc") doesn't guarantee to return a \0-terminated native string?
Member
There was a problem hiding this comment.
Member
ContributorAuthor
There was a problem hiding this comment.
Made the behavior consistent with CRuby in #187.
ankaneforce-pushed
the
ffi-backend-corruption
branch
from
April 21, 2025 01:56
07a606f to
ae9b0bbComparekou
commented
Apr 21, 2025
Member
Thanks. |
ankane
commented
Apr 21, 2025
ContributorAuthor
Thank you |
kou pushed a commit
that referenced
this pull request
Apr 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To reproduce with JRuby or TruffleRuby:
put_stringadds a null byte at the end vswrite_bytes. This is not caught by the bounds check since the underlyingFFI::Pointersize is not set.