BioJulia / Libz.jl

Fast, flexible zlib bindings.
Other
27 stars 17 forks source link

InexactError when reading big flies #49

Closed ylxdzsw closed 7 years ago

ylxdzsw commented 7 years ago

I encounter InexactError when reading BAM files

ERROR: InexactError()
 in readbytes!(::Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}, ::Array{UInt8,1}, ::Int64, ::Int64) at /home/zhangsw/.julia/v0.5/Libz/src/source.jl:141
 in fillbuffer!(::BufferedStreams.BufferedInputStream{Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}}) at /home/zhangsw/.julia/v0.5/BufferedStreams/src/bufferedinputstre m.jl:70
 in eof(::BufferedStreams.BufferedInputStream{Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}}) at /home/zhangsw/.julia/v0.5/BufferedStreams/src/bufferedinputstream.jl:10

 in _collect(::UnitRange{Int64}, ::Falcon.BamLoader, ::Base.HasEltype, ::Base.SizeUnknown) at ./array.jl:282
 in Falcon.Bam(::String) at /home/zhangsw/falcon/core/bam.jl:47

and reading the same file with minimum code cause the same error.

julia> f = open("cfdna.bam") |> ZlibInflateInputStream
BufferedStreams.BufferedInputStream{Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}}(<8.0 KiB buffer, 0% filled>)

julia> while true read(f, Int) end
ERROR: InexactError()
 in process(::Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}, ::Int32) at /home/zhangsw/.julia/v0.5/Libz/src/source.jl:165
 in readbytes!(::Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}, ::Array{UInt8,1}, ::Int64, ::Int64) at /home/zhangsw/.julia/v0.5/Libz/src/source.jl:149
 in fillbuffer!(::BufferedStreams.BufferedInputStream{Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}}) at /home/zhangsw/.julia/v0.5/BufferedStreams/src/bufferedinputstream.jl:70
 in ensurebuffered! at /home/zhangsw/.julia/v0.5/BufferedStreams/src/bufferedinputstream.jl:369 [inlined]
 in read(::BufferedStreams.BufferedInputStream{Libz.Source{:inflate,BufferedStreams.BufferedInputStream{IOStream}}}, ::Type{Int64}) at /home/zhangsw/.julia/v0.5/BufferedStreams/src/bufferedinputstream.jl:185
 in macro expansion; at ./REPL[7]:1 [inlined]
 in anonymous at ./<missing>:?

Reading files of the same format but < 200M is fine. The exact same file can also be read by GZip.jl correctly.

Both the latest released version and master branch have the same problem.

bicycle1885 commented 7 years ago

Thank you for reporting a bug.

I'm not perfectly sure, but it is highly probable that this is caused by the latest version of BufferedStreams.jl. I will fix that soon but you can checkout the previous version of it (i.e. v0.2.3) to avoid the problem if you need this immediately.

bicycle1885 commented 7 years ago

@ylxdzsw Released a new version v0.3.1 (https://github.com/JuliaLang/METADATA.jl/pull/8275). Please update and try it.

ylxdzsw commented 7 years ago

It works. Thanks a lot!