Skip to content

Fix use of pointer in write(to::IO, from::GenericIOBuffer) #57949

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

Merged
merged 4 commits into from
Apr 19, 2025

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented Mar 30, 2025

Fixes #54636

With the fixes in #57570, as far as I can tell, this is the last place where GenericIOBuffer assumes data is stored contiguously in memory.

@nhz2 nhz2 added io Involving the I/O subsystem: libuv, read, write, etc. bugfix This change fixes an existing bug labels Mar 30, 2025
@nhz2 nhz2 requested a review from jakobnissen March 30, 2025 21:06
Copy link
Member

@jakobnissen jakobnissen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Also good with the from.readable check. 👍

@jakobnissen
Copy link
Member

jakobnissen commented Mar 31, 2025

Just to be clear: GenericIOBuffer is private, and as far as I can tell, all the public constructors create buffers backed by Memory{UInt8}. So, this is not really a bugfix, but may make the code more robust.
There is a case to be made that GenericIOBuffer could be made un-generic, making it easier to reason about, and test. The genericness does seem like genericness for the sake of genericness - there is, AFAICT, no actual use case for having anything other than Memory{UInt8}.

Edit: That was completely wrong, not sure how I missed this:

julia> typeof(IOBuffer(0x01:0x02))
Base.GenericIOBuffer{UnitRange{UInt8}}

@nhz2 nhz2 added the merge me PR is reviewed. Merge when all tests are passing label Apr 18, 2025
@IanButterworth IanButterworth merged commit da99461 into JuliaLang:master Apr 19, 2025
8 checks passed
@oscardssmith oscardssmith removed the merge me PR is reviewed. Merge when all tests are passing label Apr 20, 2025
LebedevRI pushed a commit to LebedevRI/julia that referenced this pull request May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GenericIOBuffer assumes data is stored contiguously in memory
4 participants