Skip to content

Mmap and ZipArchives adverse interaction #90

@TimG1964

Description

@TimG1964

MWE:

using ZipArchives
using Mmap

function reading()
    io=open("simpleTest.xlsx")
    mm=Mmap.mmap(io)
    q = ZipArchives.ZipReader(mm)
    #q = ZipArchives.ZipReader(read("simpleTest.xlsx"))
    readme_n_lines = zip_openentry(q, "xl/worksheets/sheet1.xml") do z
        countlines(z)
    close(io)
    GC.gc()
    end
end

reading()

isfile("simpleTest.xlsx") && rm("simpleTest.xlsx")

does not work:

ERROR: LoadError: IOError: unlink("simpleTest.xlsx"): permission denied (EACCES)
Stacktrace:
  [1] uv_error
    @ .\libuv.jl:106 [inlined]
  [2] unlink(p::String)
    @ Base.Filesystem .\file.jl:1105
  [3] rm(path::String; force::Bool, recursive::Bool)
    @ Base.Filesystem .\file.jl:283
  [4] rm(path::String)
    @ Base.Filesystem .\file.jl:273
  [5] top-level scope
    @ c:\Users\tim\OneDrive\Documents\Julia\ZipArchives\TestMmap.jl:18
  [6] include(fname::String)
    @ Main .\sysimg.jl:38
  [7] run(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, error_handler::VSCodeDebugger.var"#3#4"{String})
    @ VSCodeDebugger.DebugAdapter c:\Users\tim\.vscode\extensions\julialang.language-julia-1.144.2\scripts\packages\DebugAdapter\src\packagedef.jl:123
  [8] startdebugger()
    @ VSCodeDebugger c:\Users\tim\.vscode\extensions\julialang.language-julia-1.144.2\scripts\packages\VSCodeDebugger\src\VSCodeDebugger.jl:47
  [9] top-level scope
    @ c:\Users\tim\.vscode\extensions\julialang.language-julia-1.144.2\scripts\debugger\run_debugger.jl:12
 [10] include(mod::Module, _path::String)
    @ Base .\Base.jl:557
 [11] exec_options(opts::Base.JLOptions)
    @ Base .\client.jl:323
 [12] _start()
    @ Base .\client.jl:531
in expression starting at c:\Users\tim\OneDrive\Documents\Julia\ZipArchives\TestMmap.jl:18

If I swap the definition of q to be simply ZipArchives.ZipReader(read("simpleTest.xlsx")) then this works fine. Also if I mmap(open("simpleTest.xlsx")) and then close without invoking the ZipReader, this also works fine. It is only when I use ZipReader in combination with mmap that I get an error.

I am using Windows but the issue seems not to be replicated on Linux. I am trying to include this mmap use to restore the ability to read data too big to fit memory in XLSX.jl. Obviously, Windows is an important platform for this. Currently, this issue is causing package tests to fail.

Further discussion in Discourse here.

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