Skip to content

Integer overflow in skip(s::IOBuffer, typemax(Int64)) can cause seg fault #53908

Closed
@nhz2

Description

@nhz2

Here is a MWE:

julia> s = IOBuffer()
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> skip(s, typemax(Int64))
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=-9223372036854775808, mark=-1)

julia> position(s)
9223372036854775807

julia> read(s, UInt8)

[807576] signal 11 (128): Segmentation fault
in expression starting at REPL[10]:1
getindex at ./essentials.jl:375 [inlined]
read at ./iobuffer.jl:240
unknown function (ip: 0x775177259d32)
...

This happens on nightly as well as 1.10.2, both installed using juliaup.

julia> versioninfo()
Julia Version 1.12.0-DEV.274
Commit a3f710e2a35 (2024-03-31 01:56 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions