-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorioInvolving the I/O subsystem: libuv, read, write, etc.Involving the I/O subsystem: libuv, read, write, etc.regression 1.11Regression in the 1.11 releaseRegression in the 1.11 release
Description
The maxsize
keyword argument of an IOBuffer
is documented to limit its internal size. For example:
julia> io = IOBuffer(; maxsize=3)
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=3, ptr=1, mark=-1)
julia> print(io, "foobar") # attempt to write 6 characters
julia> io # `size` ends up being only 3
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=3, maxsize=3, ptr=4, mark=-1)
julia> take!(io) # and indeed, only 3 characters were kept
3-element Vector{UInt8}:
0x66
0x6f
0x6f
The issue is that, after performing this first take!
operation, any subsequent write will not respect the maxsize
argument anymore. Re-using the same io
:
julia> io # just after `take!`, the state of `io` is reinitialized so its size is 0
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=3, ptr=1, mark=-1)
julia> print(io, "And now, qux!") # attempt to write 13 characters
julia> io # notice the inconsistency: size = 13, maxsize = 3
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=13, maxsize=3, ptr=14, mark=-1)
julia> String(take!(io)) # all 13 characters were kept
"And now, qux!"
This bug does not exist in v1.10.8 but it occurs in v1.11.0-alpha1 and is still present in 1.11.4, v1.12.0-DEV.2047 (49263b7) and on nightly (4a6ada6)
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorioInvolving the I/O subsystem: libuv, read, write, etc.Involving the I/O subsystem: libuv, read, write, etc.regression 1.11Regression in the 1.11 releaseRegression in the 1.11 release